分配和传递会话子域之间的变量 [英] Assigning and Passing Sessions Variables Between Subdomains

查看:185
本文介绍了分配和传递会话子域之间的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一个将有多个子域的网站。例如:

I am going to create a site that will have have multiple subdomains. For an example:


  • shop.domain.com

  • blog.domain.com

  • news.domain.com

  • account.domain.com

  • shop.domain.com
  • blog.domain.com
  • news.domain.com
  • account.domain.com

我想知道是否可以在子域之间传递会话变量。例如 $ _ SESSION ['variable'] 可以在上面列出的所有子域上访问。

I would like to know if session variables can be passed between the subdomains. For an example $_SESSION['variable'] would be accessible on all of the subdomains listed above.

推荐答案

您首先必须确保以所有主机都能访问的方式存储会话数据;如果他们在同一台机器上托管一切都很好,否则你可能想使用另一个会话处理程序,例如。使用数据库,memcache,...来存储会话数据。
然后,您必须确保会话ID 可用于所有子域;这可以通过设置 ini.session.cookie-domain

You first have to make sure to store session data in a way that all hosts can access them; if they are hosted on the same machine everything is fine, otherwise you might want to use another session handler which e.g. uses a database, memcache, ... to store session data. Then you have to make sure the session id is available on all subdomains; this can be achieved by setting ini.session.cookie-domain.

有关会话的详细信息,请阅读在适当的章节在精细的php手册。

For more information on sessions you should read the appropriate chapter in the fine php manual.

这篇关于分配和传递会话子域之间的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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