SCook Posted October 31, 2007 Share Posted October 31, 2007 I just installed a site on a client's server. I'm using a session based login, and have the session_start() at the top of the pages I need. However, when I first log in, the session variables I register are all there, but when I click on any page, they are gone. Does anyone have a clue as to what might be set that's cuasing this? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/75499-sessions-expiring-from-page-to-page/ Share on other sites More sharing options...
revraz Posted October 31, 2007 Share Posted October 31, 2007 Couple of things can cause this: In the PHP.INI, verify the Session Save path is correct. Make sure you use a String in your $_SESSION["array"] and not something like $_SESSION["1"] Quote Link to comment https://forums.phpfreaks.com/topic/75499-sessions-expiring-from-page-to-page/#findComment-381902 Share on other sites More sharing options...
SCook Posted October 31, 2007 Author Share Posted October 31, 2007 Well, what should the session path be, and you said use a string in teh array but not $_SESSION["1"], do you mean not the 1 or the "1". Because that's a string. That's what I do, for example: $_SESSION["userID"] = "something"; Quote Link to comment https://forums.phpfreaks.com/topic/75499-sessions-expiring-from-page-to-page/#findComment-381909 Share on other sites More sharing options...
revraz Posted October 31, 2007 Share Posted October 31, 2007 Do not have it as just a number, for some reason it will clear out the session variable on another page, make sure there is a alpha in there. Try it and see. Session path (for my webserver) has to include the entire path to my area on my webhost. Sometimes this goes a few folders before HTDOCS (again, this depends on your webhost). Try it with a String first (like "test") and see if that works before you get into the php.ini file. If the String works, you know it has to do with the number. Quote Link to comment https://forums.phpfreaks.com/topic/75499-sessions-expiring-from-page-to-page/#findComment-381913 Share on other sites More sharing options...
SCook Posted October 31, 2007 Author Share Posted October 31, 2007 Well, here's what I do. I do a print_r() with the session array. After logging in, all the values I set are there. Then when I click another button, the array prints up empty. All array keys are strings, I don't use numbers, like you said, you can't. As for the path, it's /tmp. That should be okay. I tell ya', this is a brain twiser. I might have to contact the server directly Quote Link to comment https://forums.phpfreaks.com/topic/75499-sessions-expiring-from-page-to-page/#findComment-382097 Share on other sites More sharing options...
rajivgonsalves Posted October 31, 2007 Share Posted October 31, 2007 well then some code would help also try at the end of your page and see if it would make any difference http://php.net/manual/en/function.session-write-close.php Quote Link to comment https://forums.phpfreaks.com/topic/75499-sessions-expiring-from-page-to-page/#findComment-382100 Share on other sites More sharing options...
revraz Posted October 31, 2007 Share Posted October 31, 2007 It's not ok if you don't have rights to the /tmp path on the root of the server. The location should be somewhere you can actually get to. As for the path, it's /tmp. That should be okay. Quote Link to comment https://forums.phpfreaks.com/topic/75499-sessions-expiring-from-page-to-page/#findComment-382136 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.