How to close a session after 10 minutes of inactivity.

rcleon used Ask the Experts™
I need so help in creating some mechanized way of closing or destroying a session after 10 minute of inactivity.

The application is similar to login into your bank account, a user logs in using username and password and is able to bring up several pages of there owned information.

What I need is to destroy the session 10 minutes after he has clicked for the last time.

Code sample will be greatly appreciated.


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can do this

ini_set("session.gc_maxlifetime", 600); // 600 secs, 10 min

Or you can also set this in the PHP.ini

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 600


Thanks you so much for your help,

In both of these cases, would it close after 10 min regardless of activity?

I need closing after 10 min of Inactivity.

Or is there a way to alert then than the session is going to close and extend there time.


Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

yes this is with inactivity.

And yes, you can alert the user. You would basically setup a javascript that would run while the user is inactive, and after 540 seconds say, pop up a reminder letting them know. Make the javascript run only when there is no activity. and stop/reset when there is.

Here is a little snip that would probably work.

function isInactive(){
  var msg= "Notice of Inactivity and allow confirm of redirection...";
  var temp= (window.confirm(msg)) ? '' : null;
  if (temp) window.location.href= temp;
var t= window.setTimeout("isInactive()", 5000);



Thank you soooooooooooooo much it works great.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial