Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to close a session after 10 minutes of inactivity.

Posted on 2008-11-19
6
Medium Priority
?
454 Views
Last Modified: 2013-12-13
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.

Thanks

Rafael
0
Comment
Question by:rcleon
  • 4
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
CoyotesIT earned 2000 total points
ID: 22996919
You can do this

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


0
 
LVL 8

Expert Comment

by:CoyotesIT
ID: 22996931
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

0
 

Author Comment

by:rcleon
ID: 22997117
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.

Thanks

Rafael
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:CoyotesIT
ID: 22997706
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.


0
 
LVL 8

Expert Comment

by:CoyotesIT
ID: 22997731
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)) ? 'www.devshed.com/' : null;
  if (temp) window.location.href= temp;
}
var t= window.setTimeout("isInactive()", 5000);


source: http://forums.devshed.com/javascript-development-115/alert-after-time-of-inactivity-then-click-to-logout-501444.html
0
 

Author Comment

by:rcleon
ID: 22998445
Thank you soooooooooooooo much it works great.
Rafael
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question