Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Suppose I want my site to be accessible at https://www.example.com and https://example.com.
Is it possible to set a cookie when visiting one domain so that it is accessible in the other?
Yes you can, try setting the cookie for .example.com as domain. That way, the cookie will be valid for every subdomain of yours.
For example, PHP sessions would be like this: session_set_cookie_params(0, '/', '.example.com');
session_set_cookie_params(0, '/', '.example.com');
Required, but never shown