Hi,
On one of my websites, I have some AJAX calls which are hard coded in my javascript to send their requests to http://www.example.com/ajaxfile.php. Sometimes, the AJAX request requires the user to be logged in.
Because the 'www' subdomain is hardcoded into the javascript, I've just discovered that if a user logs in at http://example.com rather than http://www.example.com any AJAX that requires they are logged in falls apart, because the script cannot find a session cookie for the 'www' sub-domain.
I've been fiddling around trying to get the session/cookie to spread across http://www.example.com and example.com but it doesn't seem to work.
My first question is, if I do this:
before I start the session, should the session cookie be accessible for example.com AND http://www.example.com?
Secondly, What else could be going wrong? Do you have any ideas that I could try?
Cheers,
Richard
On one of my websites, I have some AJAX calls which are hard coded in my javascript to send their requests to http://www.example.com/ajaxfile.php. Sometimes, the AJAX request requires the user to be logged in.
Because the 'www' subdomain is hardcoded into the javascript, I've just discovered that if a user logs in at http://example.com rather than http://www.example.com any AJAX that requires they are logged in falls apart, because the script cannot find a session cookie for the 'www' sub-domain.
I've been fiddling around trying to get the session/cookie to spread across http://www.example.com and example.com but it doesn't seem to work.
My first question is, if I do this:
Code:
session_set_cookie_params(0, '/', '.example.com');
before I start the session, should the session cookie be accessible for example.com AND http://www.example.com?
Secondly, What else could be going wrong? Do you have any ideas that I could try?
Cheers,
Richard







