woodplease Posted September 21, 2010 Share Posted September 21, 2010 how can i set a session to expire after a set amount of time, say 1 hour. i'm using the following code to create my session, but i dont know what i need to add to make it expire $_SESSION['pageviewsid'.$id] = $new; $new is the result from a calculation and $id is the page id from the URL using $_GET Quote Link to comment Share on other sites More sharing options...
joel24 Posted September 21, 2010 Share Posted September 21, 2010 when the session is started, you can set a session variable with the current unix timecode... then check to see if it is more than 1hour past the sign in time... session_start(); //log in etc etc //when login authenticated, add this line $_SESSION['sessionStart'] = time(); then in your script where it checks the user is logged in each time a page is viewed, add a line like if ((time() - $_SESSION['sessionStart']) > 60*60) { session_destroy(); exit("Session expired"); } 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.