session variables problem
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".
thanks dude, the www part is the issue.. to use
I would have that before session_start();
(that doesn't seem to fix it..)
You can use the session_set_cookie_params() function, but you need to do it on each and every page before the session_start() call.
session_set_cookie_params(0, '/', '.yourdomain.com');
thanks NogDog, you are seriously a champion mate
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread