1

webUser.php

//create/start session                
session_start();
$sessionId = session_id();
$_SESSION["sessionid"] = $sessionId;

Home.php

session_start();

$currentsessionId = session_id();

if(!isset($_SESSION['sessionid'])||($_SESSION['sessionid'] !=$currentsessionId))
{
    $message = 'Restricted to access! please login';
    header("location: login.php?error=$message");
} 
Jonnix
  • 4,121
  • 1
  • 30
  • 31
redhoc
  • 11
  • 1

1 Answers1

0

The default session expiry time is 1440 seconds (24 mins)

Reference: PHP Manual: Session configuration

To increase the lifetime in runtime, use the following command:

ini_set(’session.gc_maxlifetime’, 2*60*60); // Change the session timeout value to 2 hours
Indrasis Datta
  • 8,692
  • 2
  • 14
  • 32
  • i dont want to increase the session max time because it works fine at inactive user but the issue is that it also works for active user who working and session gets timeout after 24 minutes – redhoc Nov 25 '16 at 11:42