问题
I have such address example.com/page1
. For example visitor's user agent is like this: Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_2 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10B146
. I run session_id()
and PHP Session ID is 12345. I can see "sess_12345" file inside temporary folder. It has all session variables in it.
After some processing I redirect him/her to example.com/page2
. Visitor's user agent changes to this: Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_2 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10B146 Twitter for iPhone
. I run session_id()
again and find out that ID is still 12345. But when I check "sess_12345" file, I see that it is deleted.
This happens only when users come to my website from "Twitter for iPhone" application. I guess session file is deleted because of user-agent change, but I'm not sure. What can be the cause?
(Sessions work successfully except this case. I use CakePHP 2.4)
回答1:
Cake has a setting which will check the user agent of the browser. If it changes will destroy the session. Turn this setting off:
Session.checkAgent
来源:https://stackoverflow.com/questions/15073948/php-session-is-destroyed-after-user-agent-change