0
include('conection.php');
$db=new Database();
session_start();
echo "<div style=' background-color:white; border:solid white'>".$_SESSION['uid']."</div>";
if(!(isset(**$_SESSION['uid']**)))
{
    header('location:index.php');
}
if(isset($_REQUEST['admin']))
{
    if(base64_decode($_REQUEST['admin'])!=='over779656')
    {
        header('location:index.php');
    }
}
$r=explode(" ",base64_decode($_REQUEST['final']));



   **$_SESSION['uid']** 

value of this variable is getting unset after time cross 2 hours or some more than that, why is it so, even i am not unssetting any variable, is there any server problem or any browser problem

surya
  • 109
  • 1
  • 4
  • 13

3 Answers3

3

check session.gc_maxlifetime in yout php.ini and increase the time there

user7282
  • 5,106
  • 9
  • 41
  • 72
2

Instead of changing this in php.ini, try this to change the timeout during runtime.

ini_set('session.gc_maxlifetime', 5*60*60); // 5 hours

EDIT

NOTE: Use this code before session_start()

Ravi
  • 2,078
  • 13
  • 23
0

If you do not have access to php.ini and/or do not want to restart your server you may try the following. Look at the session.gc_maxlifetime setting with http://php.net/ini_get like so:

    ini_get('session.gc_maxlifetime')

and you may set it with http://php.net/ini_set like so

    ini_set('session.gc_maxlifetime', 3600*24);

Beware of memory issues and long running scripts though. Also like another answer says: execute before session_start().

Sjors Branderhorst
  • 2,138
  • 17
  • 25