'Session logout time duration not working on WordPress VIP website

I have implemented PHP sessions on WordPress custom pages using a custom templates. I have used session like below:

session_start();
$_SESSION["uuid"] = $uuid;
$_SESSION["email"] = $email;
$_SESSION["mdmId"] = $network_id;

Everything working perfectly fine on the whole website. Now, by default, the current session timeout is something around 20 minutes maybe. So, we want to increase session timeout up to one hour. So what do we need to do to increase the session timeout period?

I have increased session timeout duration up to one hour using the below code, it's working on localhost, but not working on WordPress VIP hosting server platform.

session_start();
$_SESSION['login_time'] = time();

if(time()-$_SESSION['login_time']>=3600)
{
  session_destroy();
  header('location:/nexplanontraining/ctp-resources/login/');
  die();
  //redirect if the page is inactive for 60 minutes
}
else{
  $_SESSION['login_time'] = time();

THE PAGE TEMPLATE GOES HERE
}


Solution 1:[1]

WordPress sessions are programmed to timeout after 48 hours. This is the code that I added to keep user logged in for 2 weeks on my website:

add_filter(‘auth_cookie_expiration’, 

‘keep_me_logged_in_for_2_week’ );

function keep_me_logged_in_for_2_week( $expirein ) {

return WEEK_IN_SECONDS; // 2 week in seconds

}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 abdelhafidh hamza