Nijn
Nijn

Reputation: 400

Is it possible to set session.gc_maxlifetime > 65535 seconds

Currently my session.gc_maxlifetime is set to default, thus 1440 seconds.

I would like to set the maxlifetime to a month, 4*7*24*60*60 seconds. However, I've read on php.net that the maximum value of session.gc_maxlifetime is 65535.

Is it therefor impossible to set my maxlifetime to more than 65535 seconds?

Upvotes: 7

Views: 10989

Answers (2)

user13601460
user13601460

Reputation:

yes you can do that by using cookies.

      setcookie("gc_maxlifetime", YOUR COOKIE VALUE, time() + YOUR 
    REQUIRED TIME);
      if(isset($_COOKIE['gc_maxlifetime']))
     {
    $_SESSION['gc_maxlifetime'] = $_COOKIE['gc_maxlifetime'];
       }

now this way the session becomes the cookie and will expire when the cookie expires.

Upvotes: 0

user5332
user5332

Reputation: 774

yes it is possible, if you do self session handler

then PHP garbabe collector will not handle your sessions

session_set_save_handler()

see https://www.php.net/manual/en/function.session-set-save-handler.php

Upvotes: 2

Related Questions