Cookies can be used in domains and subdomains .
If you have not set the domain cookie attribute, by default the cookie domain will be used as the fully qualified host name. Thus, custom targeting http://www.example.com receives a cookie with the domain www.example.com and after redirecting to example.com this cookie is no longer valid.
But if the cookie sent by your application on example.com or www.example.com contains:
Then this cookie will be valid for both http://example.com and http://www.example.com (and in fact for any subdomain as well). The client will manage it automatically, without any difficulties in apache configuration.
Instead, the material is in the application responsible for generating cookie_host_id if this PHP application is defined by default in cookie_domain , but it can also be used in session_set_cookie_params using the function. Of course, such settings are also available for Java EE or .Net applications, in all web applications you can have some control over cookie domains.
This can be used for a simple single sign-on mechanism or for tracking visitors between sub-regions, as in your case, and this is a very reliable solution.
source share