to add session expiry time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rrn
Forum Commoner
Posts: 46
Joined: Wed Apr 15, 2009 7:54 am

to add session expiry time

Post by rrn »

when ever a user login, his information(name,password..etc) will be stored in sessions and also stored in users table.
the table has following fields
1.userid 2.password

i would like to add session expiry time
what i want to do is if a user login and does not do any thing for next 15 minutes i want to redirect the user to login page.

how i can do this.any of your help will be appreciated

thanks..
rrn
Forum Commoner
Posts: 46
Joined: Wed Apr 15, 2009 7:54 am

Re: to add session expiry time

Post by rrn »

Code: Select all

$inactive = 600;
if(isset($_SESSION['<strong class="highlight">timeout</strong>']) ) 
{
 
                $session_life = time() - $_SESSION['start'];
 
                if($session_life > $inactive)
 
        { session_destroy(); header("Location: loginpage.php"); }
 
}
 
$_SESSION['<strong class="highlight">timeout</strong>'] = time();
will this code work????
rrn
Forum Commoner
Posts: 46
Joined: Wed Apr 15, 2009 7:54 am

Re: to add session expiry time

Post by rrn »

somebody pls give me a solution........... :crazy:
any help will be appreciated..
Post Reply