Home   Best Sellers   Blogging   Coding & Design   Technology   SEO   Travel & living   Career   Videos   Tips   Online tools     
Home  »     »     »  Forced session time out in php - How to implement?

Forced session time out in php - How to implement?

Tuesday, May 15, 2012

Forced session time out.

If you want to make sure that if a logged in user who is inactive on a web page for more than a specified time is forced to logout;

Here is the script to check for user inactivity and forced log out


// set timeout period in 1200 seconds (20 minutes)
$inactive = 1200;

// check to see if $_SESSION['timeout'] is set
if(isset($_SESSION['timeout']) ) {
    $session_life = time() - $_SESSION['timeout'];
    if($session_life > $inactive)
        { session_destroy(); header("Location: logout.php"); }
$_SESSION['timeout'] = time();

// your page content comes here


Try this and put your suggestions

Read How to increase php session expiry time

Share this!

How to link to this page?
If you wish to link to this page from your website, simply Copy and paste the above HTML code to your web page. It will appear on your page as:
Forced session time out in php - How to implement?.

comments powered by Disqus

This Weeks 7 Popular Posts

Subscribe to Recent Posts by Email
Stay connected to CROZOOM with regular Email notices of new Techie articles and IT Jobs. Updates will be delivered to your Inbox as soon as they are posted online.

Enter Your Email Address:  

Delivered by FeedBurner   RSS Feed

Search this Blog   

Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »