Jump to content

PHP Session default timeout


chelnov63

Recommended Posts

if you have access to the php.ini file then yes

session.gc_maxlifetime = 3600

 

you can try

 

<?php
ini_set ( string "session.gc_maxlifetime", 3600)

?>

 

 

EDIT:

 

as a note it maybe an idea to set the session everyt time its check thus resetting the timeout

thanks for the input guys... another question along the same lines:

 

<?php

session_start();

$_SESSION['size']='large';

session_destroy();

echo "Session Size: ".$_SESSION['size']; //this echoes out Session Size: large

?>

 

why does the above still echo out the value in $_SESSION['size'], after i have used session_destroy() ?

 

Cheers

 

 

try

 

<?php
session_start();
$_SESSION['size']='large';
unset($_SESSION);
session_destroy();
session_start();
echo "Session Size: ".$_SESSION['size']; //this echoes out Session Size: large
?>

 

If you are creating a new session, but want to make sure that  there are currently no sessions active by doing session_destroy(); make sure you start the session again using session_start(); or else your session data will not register properly.

thanks...the following seems to work fine

 

<?php

session_start();

$_SESSION['loggedin'] = "true";

echo "Session Size: ".$_SESSION['loggedin']; //this echoes out Session Size: large

session_unset();

session_destroy();

if(!isset($_SESSION['loggedin'])) echo "not set"; //this echoes out Session Size: large

?>

 

what is unset($_SESSION); meant for? it works correctly without it...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.