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 Link to comment https://forums.phpfreaks.com/topic/213989-session-expire-time/ 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"); } Link to comment https://forums.phpfreaks.com/topic/213989-session-expire-time/#findComment-1113653 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.