php session time out help

Hi all im trying to create a session time out but it dont seem to work please help.

[php]
//start session
session_start();

//set time
$inactive = 60;

$session_life = time() - $_session[‘timeout’];

if($session_life > $inactive) {
session_destroy();
header(“Location: login.php”);
}
$_session[‘timeout’]=time();

[/php]

[php]session_start();
// set timeout period in seconds
$inactive = 60;
// 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();[/php]
not to worry found soulution

Good to see you’ve found a solution, but FYI this is the proper way to set a 60 second lifespan for a session:

[php]<?php
session_set_cookie_params(60);
session_start();[/php]

http://www.php.net/manual/en/function.session-set-cookie-params.php

Sponsor our Newsletter | Privacy Policy | Terms of Service