My site uses PHP sessions to keep track of a logged in user. Every page has session_start(); implemented properly, however in chrome when I place www. in from of the domain name it does not use the session variables. When I replace it back without the www. it works fine again, so the variables are not unset but rather just not being used.
In Firefox strangely it is the other way around. www. works and without does not. Is there a way around this? I’m having trouble because I’m using PayPal to redirect to my site and I can’t have my users have to log out and back in directly after.
www.example.comandexample.comare NOT the same website. They usually are, but only by convention.www.example.comis a subdomain ofexample.comFor this reason, cookies set on
example.comwill NOT be used onwww.example.comand vice versa, because it would be unsafe to assume they are the same thing.You can override this behaviour to some extent by allowing the session cookie to work on all subdomains as well as the main domain by setting the php.ini setting
session.cookie_domainto.example.com(replace with your own domain name, of course)