After remove the www extension from addressbar session not working

余生颓废 提交于 2019-12-13 09:18:31

问题


After login in this url www.example.com, if I remove the www extension from address-bar the login detail value doesnot keep by session.


回答1:


Try creating a redirect function from non-www to www. See this topic: WWW to non-WWW Redirect with PHP




回答2:


Your session is maintained by a cookie. When you log on to www.example.com, a cookie is saved for this domain by default, which is represented with every request to a URL in this domain. example.com is a different cookie domain, and the cookie won't therefore be presented.

Solutions are to either redirect from example.com to www.example.com as Andrei suggested, or to make the cookie domain match as Adnan suggests - both valid answers.




回答3:


put this in your globals, or in your includes file, or just add it before any session_start() call.

ini_set("session.cookie_domain",".example.com");


another option would be to to add this:

php_value session.cookie_domain .example.com

to your .htaccess




回答4:


Try clearing browser cache deleting temporary files and prefetch files clear dns from cmd ipconfig/flushdns

re open browser login, writing or removing www should not alter with session since it runs on server.

make sure you are not Re - Starting session.



来源:https://stackoverflow.com/questions/10410591/after-remove-the-www-extension-from-addressbar-session-not-working

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