Locate your session storage
This topic discusses how to locate where your session files are stored. The Commerce application uses the following logic to store session files:
- If you configured memcached, sessions are stored in RAM; for more information, see Use memcached for session storage.
- If you configured Redis, sessions are stored on the Redis server; for more information, see Use Redis for page caching or session storage.
If you’re using the default file-based session storage, we store sessions in the following locations in the order shown:
A sample snippet from
1 2 3 4 5 'session' => array ( 'save' => 'files', 'save_path' => '/var/www/session', ),
The preceding example stores session files in
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.
Garbage collection configuration
To clean up expired sessions, Commerce 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).
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.
On some operating systems (Debian/Ubuntu), the default
session.gc_probability directive is
0, which prevents the garbage collection handler from running.
You can overwrite the
session.gc_ directives from the
php.ini file in the
1 2 3 4 5 6 7 'session' => array ( 'save' => 'db', 'gc_probability' => 1, 'gc_divisor' => 1000, 'gc_maxlifetime' => 1440 ),
The configuration depends on the traffic and specific needs of a certain Commerce application.