Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 27b0583

Browse files
Merge pull request #8053 from victorpetryk/garbage-collection-configuration
Session garbage collection configuration
2 parents ef53542 + 834a5e6 commit 27b0583

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/_includes/config/locate-session.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,25 @@ The preceding example stores session files in `/var/www/session`
2727
### `php.ini` example {#session-where-phpini}
2828

2929
As a user with `root` privileges, open your `php.ini` file and search for the value of `session.save_path`. This identifies where sessions are stored.
30+
31+
## Garbage collection configuration {#session-gc}
32+
33+
To clean up expired sessions, Magento calls the `gc` (_garbage collection_) handler randomly according to a probability that is calculated by the `gc_probability / gc_divisor` directive. For example, if you set these directives to `1/100` respectively, it means a probability of `1%` (_probability of one call of garbage collection per 100 requests_).
34+
35+
The garbage collection handler uses the `gc_maxlifetime` directive—the number of seconds after which the sessions will be seen as _garbage_ and potentially cleaned up.
36+
37+
On some operating systems (Debian/Ubuntu), the default `session.gc_probability` directive is `0`, which prevents the garbage collection handler from running.
38+
39+
You can overwrite the `session.gc_` directives from the `php.ini` file in the `<magento_root>/app/etc/env.php` file:
40+
41+
```php
42+
'session' =>
43+
array (
44+
'save' => 'db',
45+
'gc_probability' => 1,
46+
'gc_divisor' => 1000,
47+
'gc_maxlifetime' => 1440
48+
),
49+
```
50+
51+
The configuration depends on the traffic and specific needs of a certain Magento application.

0 commit comments

Comments
 (0)