siri Posted September 23, 2006 Share Posted September 23, 2006 I just want to know how I can clear the session variable after a specified time.I tried using the sleep function as follows:sleep(60);unset($_SESSION['members'];But it's not working. Link to comment Share on other sites More sharing options...
reportingsjr Posted September 23, 2006 Share Posted September 23, 2006 Make sure you have that at the very bottom of the page and done have any content that is javascript and loads when the page loads, or it wont get done until the 60 seconds are over.First: the default time a php script can run before its stopped by the server is 30 seconds, but there is a function to raise this. Just google it .Second: you need the close the unset parenthesis, because you are missing the end one ( unset($_SESSION['members']; is what you have, it should be unset($_SESSION['members']);It might be easier to just use session_destroy(); if you want to destroy all sessions. Link to comment Share on other sites More sharing options...
SFB Posted September 23, 2006 Share Posted September 23, 2006 You could also set the session to something as something like "FALSE" or "0" and check for that in your script. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 25, 2006 Share Posted September 25, 2006 If you use the sleep function, you are going to make the user wait that long for the page to load. It would probably be best to use output buffering to explicitly send the page to the user, and then use the sleep function after it has been sent. But, if the user notices that the page hasn't finished loading and presses the stop button, it might never execute the statement to destroy the session. If you want this to apply to all session information, you can change the configuration option to have the session expire after 1 minute. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now