By default Piwik uses the filesystem as a session handler. If your Piwik environment consists of multiple servers a common problem is that multiple sessions are created per user meaning a user might have to log in multiple times and a log out might actually log out a user only on one server. To workaround this there are two options:
- Use the database to handle sessions
- Use Redis to handle sessions (described in this FAQ). Redis is usually faster than a database and we recommend it in case one has Redis already configured as a Cache or for Queued Tracking.
To use Redis as a session handler follow these steps:
- Install Redis see Redis Quickstart
- Install the PHP extension phpredis
- Configure Redis as PHP session handler in
php.inion each of your server.
session.save_handler = redis session.save_path = tcp://127.0.0.1:6379?database=10 ; In case you are using queued tracking or Redis as a cache: Make sure to configure a different database! Otherwise queued requests will be flushed ; multiple servers can be configured comma separated session.save_path = "tcp://host1:6379?weight=1&database=2, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2"
- Don’t forget to restart your webserver
- Once successfully setup, make sure there is no Piwik default session handler configured by setting the
session_save_handlerto an empty value in the config file
config/config.ini.phphave to make this change on each of your server.
[General] session_save_handler = ""