允许php会话转移到子域 [英] Allow php sessions to carry over to subdomains

查看:122
本文介绍了允许php会话转移到子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对所有用户数据使用php会话(不是cookie,除了会话ID cookie),并且当用户转到其个人资料user.mydomain.com时,他们会立即注销,直到删除子域。 p>

是否可以接受来自所有域的会话,只要其* .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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆