如何从共享SESSION变量的子域中排除一个子域 [英] how to exclude one subdomain from subdomains that share SESSION variable
问题描述
我有一个无Cookie的子域(静态),直到我使用此代码使我的会话变量在所有子域中可见:
session_set_cookie_params(0,'/','。example.com');
显然,我已经失去了静态子域的无Cookie特性。 / p>
如何在所有子域中除了静态域外显示一个会话变量?
感谢您的帮助
我遇到了类似的问题,我认为我的解决方案将帮助您您的无Cookie静态域。
我想在2个子域上共享会话:
- www.example.com
- shop.example.com
但不包括该会话,并在
上使用自己的会话- admin.example.com
要设置要在两个域中使用的会话,如前所述,您必须设置cookie参数:
session_set_cookie_params(0,'/','。example.com');
但是,这会与admin.example.com会话的Cookie冲突。
解决方案是在管理网站中设置会话名称,以便与其他网站中的会话名称不同。例如:
session_name(AdminPHPSESSID);
请参阅 http://www.php.net/session_name 了解详情。
I had a cookie-free subdomain (static) until I used this code to make my session variable visible in all sub-domains:
session_set_cookie_params(0,'/','.example.com');
apparently, By doing so, I have lost cookie-free characteristic of the "static" subdomain.
How could I have one session variable visible in all subdomains except the static one? thank you for helping
I was having similar problem as you, and I think my solution will help you for your cookie-less static domain. I've described my issue and subsequent solution below so hopefully you can use it to solve your issue.
I wanted to share the session on 2 subdomains:
- www.example.com
- shop.example.com
But exclude that session, and use its own session on
- admin.example.com
To set the session to be used across the two domains, as you described you will have to set the cookie params:
session_set_cookie_params(0,'/','.example.com');
However, this will conflict with the cookie for the admin.example.com session.
The solution is to set the session name in the admin site so it differs to the session name in the other sites. For example:
session_name("AdminPHPSESSID");
See http://www.php.net/session_name for more info.
这篇关于如何从共享SESSION变量的子域中排除一个子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!