Session Lottery

Can someone explain what a session lottery is? I have added a default session configuration file for the Laravel framework.

Questions: 1. It states that some session drivers must manually sweep their storage location. Can someone describe this process and why is it necessary? What session drivers require this action? 2. Why do I need a lottery? If we talk about some form of storage (database) is complete, why should it be random? Why can't it scroll through old sessions when it detects that the driver is full?

/* |-------------------------------------------------------------------------- | Session Sweeping Lottery |-------------------------------------------------------------------------- | | Some session drivers must manually sweep their storage location to get | rid of old sessions from storage. Here are the chances that it will | happen on a given request. By default, the odds are 2 out of 100. | */ 'lottery' => array(2, 100), 
+5
source share
1 answer

So, a session is a piece of data that is stored on the server for a certain time.

Imagine that you are using a file folder to store sessions. There must be a moment when old sessions need to be cleared. Since it is not possible to automatically check files every x hours, session files are checked for specific requests.

This parameter is the probability that this check will happen. In this case, 2 out of 100 for each request.

I think the only session driver that currently needs this is the database driver.

If you expand the vault when it is full, chances are that new sessions will not be able to start until the vault is empty.
If you put a repository on every request, all your requests will be very slow.

+4
source

Source: https://habr.com/ru/post/1243223/


All Articles