简体   繁体   中英

CakePHP Session seems to be destroyed after redirect on new server

I have 3 working apps that I am moving from one production server to another. All 3 of the apps use Auth. All 3 work fine on the original server. On the new server, one of these apps works as it should (it happens to be CakePHP 1.3) ie after logging in the user's session data (like user name and role) is available in my PagesController after the redirect.

On the other 2 apps (one is 1.3 and the other is 2.3), after the login redirect, the session data seems to be gone. I have confirmed this by debugging $this->Auth->user() in the PagesController. I have also confirmed that the session data IS there after the call to $this->Auth->login() in the UsersController but is gone after the redirect.

Because these are apps that I have been using for years, I am confident that the problem is some configuration issue on the new server - something like a directory permission. I have reviewed all permissions and can't find a problem. I have compared the permissions on the one app that works to the ones that don't and I'm stumped.

Any suggestions?

Try with ob_start() or session_start() in the top of the AppController before starting the class.

Thanks..!

I have also posted this question and workarounds on the CakePHP Google group and added more detail. Please go to: https://groups.google.com/forum/#!topic/cake-php/ORfK1b9AYTU

The problem is that sessions are not starting after the redirect. The work-around is to call CakeSession::start() in AppController in beforeFilter() , although this should not be necessary.

Ken

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM