Debugging browser redirects

I am using CakePHP with Auth and ACL components. My page loads with a fine for unregistered users, but if I try to log in as a registered user, I get an endless redirect cycle in the browser.

I am sure that this is some kind of permission problem, but the problem exists even for users who have permissions for everything. The only way to prevent this behavior is to enable '*' in my AppController beforeFilter method.

What is the best way to debug this problem?

Thanks!

+6
debugging php cakephp
source share
3 answers

For debugging purposes, try pasting this first thing into your AppController::beforeFilter() :

 $this->log("Here: {$this->here}, coming from: " . $this->referer(), LOG_DEBUG); 

This will be logged in /app/tmp/logs/debug.log . You can also combine this with an override of the redirect method in the AppController :

 function redirect($url, $status = null, $exit = true) { $trace = debug_backtrace(); $this->log("Redirecting to: " . Router::url($url) . ", initiated in {$trace[1]['file']} on line {$trace[1]['line']}", LOG_DEBUG); parent::redirect($url, $status, $exit); } 
+10
source share

Also make sure that you check the settings of your Auth component in your app_controller, are configured correctly.

http://book.cakephp.org/1.3/en/The-Manual/Core-Components/Authentication.html#setting-auth-component-variables

I tend to explicitly define them all. Maybe check something like this http://www.webdevelopment2.com/cakephp-auth-component-tutorial-1/ Just make sure everything is set up correctly.

Another thing I found, sometimes, beforeFilter () can sometimes knock out the Auth setting in your app_controller, so maybe try in your controllers having

 parent::beforeFilter(); 

To make sure your app_controller beforeFilter () is executed.

+2
source share

The first thing I would like to check out is the user controller login method. If they are executed correctly, you usually direct all unverified / authorized traffic to the input controller. However, if you have not given permission from the public, this is likely to lead to an endless cycle. So check app_controller (or wherever you save Auth / ACL permissions) and make sure Users.login is public.

+1
source share

All Articles