开发者

Assigning and Passing Sessions Variables Between Subdomains

开发者 https://www.devze.com 2023-03-17 03:32 出处:网络
I am going to create a site that will have have multiple subdomains. For an example: shop.domain.com blog.domain.com

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

I would like to know if se开发者_Go百科ssion variables can be passed between the subdomains. For an example $_SESSION['variable'] would be accessible on all of the subdomains listed above.


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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号