BelovedDoll Posted September 14, 2010 Share Posted September 14, 2010 Pesky me again. This time I`d like to have my session code looked over. I`m having some problems with it. When a user logs into my website (provided they enter all the right information), they will log in no problem. However, the session doesn`t last as long as I`d like it and it seems to be unpredictable with how long it`ll last. Such as, one day it`ll last 5 hours even with closing the browser. The next day it might last 20 minutes. The next day it may log the person out if they close the browser. I`d looked around on the net to see what could be going wrong with my code but I guess I`m not getting it. Any more epxerienced set of eyes want to look it over and give me their opinion: function RemoveSession() { $_SESSION = array(); if (isset($_COOKIE[session_name()])) { @setcookie(session_name(), '', time()+(60*60*24*365), '/'); } } Is it even possible to make a session last as long as cookies can? Like have it last a month even though the person closes the browser and shuts off their computer and doesn`t visit for a few days? I`d like to have it start out lasting a full month if possible. Quote Link to comment Share on other sites More sharing options...
btherl Posted September 15, 2010 Share Posted September 15, 2010 What is RemoveSession() intended to do? If you want to change the session cookie attributes, there are configuration options described here: http://www.php.net/manual/en/session.configuration.php , with the default being "until the browser is closed". Session life depends on two things - how long the cookie survives in the browser, and how long the session file lasts on the server. The first depends on the cookie options, the second depends on your server's configuration, and sometimes can be beyond your control. Quote Link to comment Share on other sites More sharing options...
BelovedDoll Posted September 24, 2010 Author Share Posted September 24, 2010 It deletes the existing session, according to the notes left by the original programmer who wrote it 7 years ago. I took a look at the site you directed me to but I`m only more confused. I don`t know which item I would need or how to write them. Quote Link to comment 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.