we have set
session_gcmaxlife=5
in php.ini but session variable on server are not destroyed after 5 seconds
We want to set the maximum life of the session in PHP to be 5 seconds.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
OK – to me a 5 second session sounds rather pointless (as a session is supposed to maintain the application state in a stateless application… yeah).
Your best bet is to probably save an expiry timestamp (
time()+ 5 seconds) in the session, something like$_SESSION['expires']– then whenever you start a session, check to see if that variable exists and, if so (and is in the past), kill the session off and start again.[EDIT]
This is one other possibility that might work, but you’d need to create an object to manage your session – then you could have a
kill()method that could be invoked if the session has expired and in the__destruct()method – it’s not fullproof as the destructor will only be invoked when the object is destroyed – but it should work.