cakephp lost session variable when redirect

后端 未结 5 1031
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-17 04:48

I have problems with a session variable, users log into the app and then it sets a session variable but when it redirects to the next controller it isn\'t there.

At

5条回答
  •  猫巷女王i
    2020-12-17 05:25

    I was losing session information after a login call too and after searching for a while I found many different ways to fix my issue. I only regret that I don't fully understand what is causing the issue, but I imagine it has to do with php's session configuration.

    1. As you mentioned, changing Security.level to low fixed the issue for me Configure::write('Security.level', 'low');
    2. Changing the session save configuration to php fixed the issue for me too: Configure::write('Session', array( 'defaults'=>'cake', ));
    3. And finally adding a timeout worked too (which I ended up using): Configure::write('Session', array( 'defaults'=>'php', 'cookieTimeout'=> 10000 ));

    All these found in /app/Config/core.php

    I post this hoping someone is able to make sense of what is going on underneath. I feel understanding the root of the issue would make a better job of answering your question.

提交回复
热议问题