0
session_cache_expire( 20 );
session_start(); // NEVER FORGET TO START THE SESSION!!!
$inactive = 1200;
if(isset($_SESSION['start']) ) {
    $session_life = time() - $_SESSION['start'];
    if($session_life > $inactive){
        header("Location: user_logout.php");
    }
}
$_SESSION['start'] = time();
if($_SESSION['valid_user'] != true){
header('Location: ../index.php');
}else{

I'm making an online examination system. I'm using PHP and MySQL.

I want to set the session time, but don't know how. Please help me.

Thanks in advance

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
Hitesh Solanki
  • 403
  • 2
  • 5
  • 9

1 Answers1

0

i am going to set session time

Don't touch it ever.
Default session timeout is good enough for anyone.

You are confusing the session timeout with whatever application timeout.

Instead of playing with session timeout you have to store whatever timings in the session itself.
But not to throw a user to login page silently to to warn them gracefully

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345