php - Remove one hour from time() -
I have an online system and after 60 minutes of inactivity one user needs to log out.
The current code is now reduced to 30 minutes.
$ cut = time () - 30 * 60; Now I have thought that the following will remove one hour so that time is 60 minutes.
$ cut = time () - 60 * 60; This is a complete code that happens. After 60 minutes of inactivity I need a person to log out.
// users expire 60 minutes $ final = $ _SESSION ['time']; $ Cut = time () - 60 * 60; If ($ last <$ cut) {session_destroy (); $ Get = $ _GET; $ Location = 'login.php? Timeout = true '; Get foreign currency ($ $ key = & gt; $ item) {$ location. = '& Amp ;;. $ Key "=". $ Item; } Header ('location:'. $ Location); } And $ _SESSION ['time'] = time (); Now that code does not work, I do not think so.
Use strontem () It can be easy
Like a session This way, every time the user makes a request, it declares.
$ _ session ['time'] = strtotime ("now and"); coding part
$ last = $ _SESSION ['time']; $ Cut = strotman ("- 60 minutes"); If ($ last & lt; $ cut) // can also use the stratotype ("- 60 minutes") directly {// session_destroy (); Not set ($ _ session ['time']); // Only use the inorder to delete that session = $ _GET; $ Location = 'login.php? Timeout = true '; Get foreign currency ($ $ key = & gt; $ item) {$ location. = '& Amp ;;. $ Key "=". $ Item; } Header ('location:'. $ Location); } And $ _SESSION ['time'] = stratetime ("now"); Ensure that the session is started on every page. Works fine ...
Comments
Post a Comment