When I go to localhost/index.php?r=gii I am redirected to localhost/index.php?r=gii/default/login. When I log in with the password I set in the configuration I am redirected to the login page again. I am caught in this infinite login loop.
To be specific I am 302 redirected from localhost/index.php?r=gii/default/login to localhost/index.php?r=gii/default/index, then 302 redirected from localhost/index.php?r=gii/default/index to localhost/index.php?r=gii/default/login.
Read on to find the solution to this nasty issue.
I need to use the Gii Module to generate code for controllers, views, models, modules, forms for my database models.
To find out if this is the cause simply view the cookies of localhost and see if there are any cookies there.
If the cause of the Gii infinite loop issue is due to cookies not being saved in the web browser, simply use a domain that the web browser would accept cookies from. The domain can be anything because it is just going to be a synonym of localhost on your machine. Let's say the domain is www.chtoen.com.
Open and edit C:\Windows\System32\drivers\etc\hosts with admin privileges to add this line:
Then use your browser to go to http://www.chtoen.com/index.php?r=gii/default/login and try again. This time observe that cookies are set correctly. You should see a cookie named PHPSESSID.
Or you can use a browser that would accept cookies from localhost. As long as cookies are set correctly the PHP session can be maintained, and Yii and Gii will be able to track the PHP session and Gii will work correctly.
Questions? Let me know!