PHP会话登录不同的url与www和没有www? [英] PHP session login different for url with www and without www?
问题描述
我在会话登录调试,当我登录到www.domainname.com会话将只设置为www。
当我要去
我已设置会话cookie_domain,但不能正常工作。
任何人都可以帮助我吗?为什么?
我知道这个问题和谁先来了?鸡蛋还是鸡? >
我对这个问题有很多麻烦。
但是...如果你使用PHP,我找到了一个解决方案:
在你的登录脚本中插入第一行
<?php
session_set_cookie_params(0,'/','www.yourdomain.com');
session_start()
?>
或您可以尝试 yoursubdomain.yourdomain.com
www.yourdomain.com
。
它适用于我。希望它帮助其他用户也。
I am debugging on session login, when i am login to www.domainname.com the session will be only set for with www.
When i am going to url domain.com, session login is ignored, and i will be prompted to login form again.
I have set session cookie_domain also, but not working.
Any one can help me? why?
I know this question is as old as "Who came first? The egg or the chicken?"
I had a lot of trouble about this issue. But... if you're using php I've found a solution:
In your login script insert in the first line
<?php
session_set_cookie_params(0, '/', 'www.yourdomain.com');
session_start()
?>
or you can try yoursubdomain.yourdomain.com
instead www.yourdomain.com
.
It works for me. Hope it help other users too.
这篇关于PHP会话登录不同的url与www和没有www?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!