I have some code that will log the user after x-second inactivity. The problem is that it is logged out before the specified time, it also does not count inactivity.
This code is:
& lt ;? Php $ _SESSION ['logintime'] = time (); If ($ _ session ['logintime'] & lt; time () + 10 * 60) {$ error_msg = "Logout due to inactivity"; ShowLoginPasswordProtect ($ ERROR_MSG); Session_destroy (); }?
good $ _ session ['logintime']
Timestamp which they are logged in (hopefully) will be always less than the current timestamp, because you add one for each second, then you need to do this:
& lt ;? Php if ($ _ session ['logintime'] + 600 & lt; time ()) {$ error_msg = "Logout due to inactivity"; ShowLoginPasswordProtect ($ ERROR_MSG); Session_destroy (); }? & Gt;
In this way the statement will go away if 600 seconds have passed.
Comments
Post a Comment