简体   繁体   中英

Different session variables between Domain and Subdomain

Is it possible to setup your two different project on a same domain and same server but different SESSION variables and point to different folders?

One is on maindomain.com (share session variables with subdomains except dashboard.maindomain.com) and one is 'dashboard.maindomain.com'

This implies that session variables must be shared between the primary domain and any subdomain, except dashboard.

Yes, it's possible.

In theory, it should be as easy as just properly configuring different cookie domains, as well as having separate storage (eg different file directories, in case you're using file-based sessions).

However, because cookies for example.com would be valid for and sent by clients to all subdomains, make sure to use a different session cookie name for your dashboard. subdomain. That way, it won't attempt to process cookies that weren't intended for it. In addition, that's a security concern because your dashboard. app will now effectively be able to sniff cookies that are only intended for your main domain and other subdomains.

So, while technically possible, it might not be a good idea to do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM