I have a CakePHP 1.2 build that I just upgraded from 1.1. Unfortunately, session is not working correctly.
I have spent hours on other threads on stackoverflow, tried solutions offered, and so far, nothing has worked.
When a user logs in at: accounts/login, I set the session in accounts_controller.php like this.
$this->Session->write('Account', $someone['Account']);
print_r($this->Session->read());
$this->redirect("/accounts/profile");
exit;
The session is for sure being saved, as the read shows all the correct session information. As soon as it redirects to /profile, however, everything is gone.
function profile() {
print_r($this->Session->Read());
The output of this is:
Array ( [Config] => Array ( [userAgent] => [time] => 1376738563 [timeout] => 10 ) )
I have set the cake security level to low in core, and it still doesn't work.
Configure::write('Security.level', 'low');
My problem is essentially identical to this one: Cakephp session is destroyed after redirect
But I know for SURE my session is being saved (I opened the session file on the harddisk to verify). And there were no other solutions given to that issue.
I also found this thread very helpful, but the solutions given there haven't worked for me either: cakephp lost session variable when redirect
I am not very skilled with php.ini settings. It is possible that I missed something very simple, but I'm about to pull out my hair. Can you give me a clue on what I might be missing?
I'd be happy to post my php.ini file and core.php cake file if anyone would find that helpful.
Here are the pertinent core settings:
Configure::write('Session.save', 'cake'); //I have tried 'php' also
Configure::write('Session.cookie', 'CAKEPHP');
Configure::write('Session.timeout', '120');
Configure::write('Session.start', true);
Configure::write('Session.checkAgent', false);
Configure::write('Security.level', 'low');
I added these below after reading this thread: cakephp lost session variable when redirect It didn't work before or after. :)
Configure::write('Security.cookie', 'cakephpfdebackend');
Configure::write('Session.cookieTimeout', 10000);
Configure::write('Session.cookie_secure',false);
Configure::write('Session.referer_check' ,false);
Configure::write('Session.defaults', 'php');
Cookies are enabled on my browser, and I've tried both firefox and chrome. I am working on localhost right now, so I have full access to all files. Please ask any question necessary - I'm desperate.
EDIT: I was able to push my site up to a live server where I knew everything worked for other sites on that server. And my site works on that server just fine. This verifies that the problem is with the settings on my computer/apache/php.