We fixed an issue we had with a browser from not being able to log in on subdomains by adding the following line of code.
ini_set('session.cookie_domain', '.'.get_domain('http://'.$_SERVER['SERVER_NAME']));
The get_domain function gets the domain of a site so that “sub.sub.domain.com” will return “domain.com”. We prepend a “.” so that our sessions are good across all subdomains.
That fixed the issue of not being able to login but the problem now is that ever since we added this line of code we will randomly not be able to login because the sessions aren’t created and are just NULL.
I say randomly because I can’t figure out what’s causing it. One day a user is able to login, they try to login the next day and it doesn’t work. Clearing the cookies will usually solve the issue. Any idea what I might be doing wrong? I’ve tried googling but haven’t found anything that has helped, our users are getting frustrated and I’m running out of ideas. Any help is really appreciated.
Turns out I had forgotten to change this setting in one of the headings which was throwing everything out of whack.
(Sorry for answering my own question, up voted everyone for the help)