允许 php 会话转移到子域 [英] Allow php sessions to carry over to subdomains
本文介绍了允许 php 会话转移到子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对所有用户数据使用 php 会话(不是 cookie,会话 id cookie 除外),当用户访问他们的个人资料 user.mydomain.com 时,他们会立即注销",直到删除子域.>
有没有办法接受来自所有域的会话,只要它是 *.mydomain.com
解决方案
这里有 4 个选项.
把它放在你的 php.ini 中:
session.cookie_domain = ".example.com"
或者在您的 .htaccess 中:
php_value session.cookie_domain .example.com
或者作为脚本中的第一件事:
ini_set('session.cookie_domain', '.example.com');
或者在您站点的 php-fpm 池配置中:
php_value[session.cookie_domain] = .example.com
I use php sessions (not cookies, except for session id cookie) for all user data, and when a user goes to their profile user.mydomain.com they are immediately "logged out" untill then remove the subdomain.
Is there a way to accept sessions from all domains as long as its *.mydomain.com
解决方案
Here are 4 options.
Place this in your php.ini:
session.cookie_domain = ".example.com"
Or in your .htaccess:
php_value session.cookie_domain .example.com
Or as the first thing in your script:
ini_set('session.cookie_domain', '.example.com' );
Or in your php-fpm pool configuration for your site:
php_value[session.cookie_domain] = .example.com
这篇关于允许 php 会话转移到子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文