Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I troubleshoot a CakePHP application stuck in a redirect loop?

I've got a CakePHP site that is stuck in a redirect loop. I've removed every piece of code that does a redirect & I've turned off autoRedirect on the Auth object.

This occurred when I logged out of the site and has persisted even after deleting all cookies and just trying to load the homepage. The index action is in $this->Auth->allow.

I should not, it keeps trying to redirect me to /users/login which then redirect loops. The login action is also in the allowed list

Does anyone have any ideas what could cause this?

like image 402
Glenn Slaven Avatar asked May 01 '09 06:05

Glenn Slaven


3 Answers

Your <cake>/app/app_controller should have a beforeFilter() method with all behaviors of Auth component. One of those behaviors is where to send when a user is not logged in.

you will be looking for something like:

// If cake should redirect automatically or you will do it in the User.login()
$this->Auth->autoRedirect = true; 
// And if the autoRedirect is true, where to redirect
$this->Auth->loginRedirect = '/user/login';

G'luck

like image 24
Fernando Barrocal Avatar answered Nov 03 '22 08:11

Fernando Barrocal


This also occurs in CakePHP 1.3 if you add a custom component that extends Component instead of Object.

like image 150
Steve Tauber Avatar answered Nov 03 '22 07:11

Steve Tauber


hey sometimes, if you db connection are wrong,,, the application will be trying connect to the mysql, and will be in looping. So, look allways if the database config are right.

good bye.

like image 25
jean martins Avatar answered Nov 03 '22 08:11

jean martins