J
J
JackShcherbakov2018-03-26 20:01:43
PHP
JackShcherbakov, 2018-03-26 20:01:43

Why is the session file not deleted after session.gc_max_lifetime expires?

Hello colleagues! I recently encountered the following problem:
I need the minimum idle time between requests to be 3 seconds (purely for example and clarity)
Here is the server configuration:

session.gc_probability = 1
session.gc_divisor = 1
session.gc_maxlifetime = 3

At this stage, I conclude that the sequence of actions described below will lead to the fact that the browser will be empty, since there is no file on the server anymore.
So, here is the sequence itself:
  1. I run the script below
    <?php 
                              session_start();
                              $_SESSION["age"] = 100;
                              echo $_SESSION["age"];
    //создать на сервере файл сессии с age==100
                               ?>


  2. I run this script
    <?php
    session_start();
    echo $_SESSION["age"];
    ?>
    //в браузере 100

  3. Waiting more than 3 seconds
  4. Renovate scenario number 2

Why is the browser still 100 and not empty. And why is there still a file on the server?
Many thanks in advance to everyone who helps

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
neol, 2018-03-26
@neol

If the server is Debian or derivatives, then the GC for sessions cannot work there in principle due to access rights restrictions - https://serverfault.com/questions/511609/why-does-...
If you also set session.save_path then there are chances.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question