So I've used sessions a heap before but they have decided they don't like me anymore and are not working.. I cannot for the life of me work out why and it's driving me crazy..
I have a page that sets a login name in $_SESSION['login_name'] and when I try to use that on another page, say to echo it, it is not there (not on any of my pages).. Then I go back to the login page (the one that set it) and find that it won't echo there anymore either. So it's kind of like a session that only lives while I'm on that one page...
As a test I created a real simple page to set $_SESSION['test']. I echo'ed that on another page successfully but it wont echo on the login page.. it's like I have a session destroy hiding in the login page.. only I don't.
And yes, I do have session_start(); at the top of my php.
Any suggestions before I start smashing my head on the wall?
Anything in the PHP error logs about session_start() not working?
Also, you can get hit by a problem with the session ID cookie if you access some pages with the "www." sub-domain in the URL and some without it. You can avoid that issue if you set the session.cookie_domain setting to ".example.com" (note the leading dot), which will ensure the cookie is exchanged regardless of whether the page is accesses via "http://example.com" or "http://www.example.com".
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
thanks dude, the www part is the issue.. to use
ini_set('session.cookie_domain', '.domain.com');
I would have that before session_start();
correct?
(that doesn't seem to fix it..)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks