I want to develop a web application that will require multi-subdomain Sessions. But I’m unable to find an appropriate guide or tutorial for this, I’m sharing my problem with you guys.
Suppose I have two domains: phpsess1.epizy.com and phpsess2.epizy.com
I want to share the sessions created at 1st domain with 2nd domain.
So please somebody help me with this.
PHP sessions work by storing some data on the server, which is then linked to a visitor’s browser with a cookie. Normally, the session cookie is created for the same domain as your website (e.g. phpsess1.epizy.com), and is not sent on other websites.
You could try to update the session cookie domain to point to
.epizy.com. But this will share the cookie with ALL other subdomains, not just a specific other subdomain. And given that epizy.com is a shared domain, that’s quite risky. If it’s your own domain, then it’s probably safe enough.
After that, you may be able to call
session_start() on the other subdomain, and it may resume the session. But that’s only if the session store is accessible. This may work if both subdomains are hosted on the same IP address and hosting volume, and even then it may be restricted by server security.
So if I park my custom domain (say phpsess.com) to one of IF accounts, even then I may not be able to share PHP sessions among my subdomains as the hosting volumes are inaccessible by each other subdomains (as far as I know).
Did I got it??
No, that should work. Hosting volumes are assigned per account, not per domain name. So every domain name on the same hosting account uses the same IP address and hosting volume.
So if you have a custom domain linked to a hosting account, and create subdomains of your own domain on that same account, you’ve got the best shot at making it work.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.