PHP session is destroyed after user agent change

只愿长相守 提交于 2019-12-13 01:29:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!