Assigning and Passing Sessions Variables Between S

2019-05-04 02:19发布

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 session variables can be passed between the subdomains. For an example $_SESSION['variable'] would be accessible on all of the subdomains listed above.

1条回答
Root(大扎)
2楼-- · 2019-05-04 02:56

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.

查看更多
登录 后发表回答