问题
I am going to create a site that will have have multiple subdomains. For an example:
shop.domain.comblog.domain.comnews.domain.comaccount.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:
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.
来源:https://stackoverflow.com/questions/6546999/assigning-and-passing-sessions-variables-between-subdomains