Shopware, by default, uses the session storage configured in PHP. On most installations, this is the file system. So, in smaller setups, you will not need to take care of sessions. For larger setups with a lot of traffic, or that are using clustering however, you will most probably want to configure alternative session storage such as Redis, in order to reduce the load on the database.
As Shopware by default uses the settings configured in PHP, you can reconfigure the Session config directly in your php.ini
. Here is an example to configure it directly in PHP.
session.save_handler = redis
session.save_path = "tcp://host:6379"
Please refer to the official PhpRedis documentation for all possible options.
If you don't have access to the php.ini configuration, you can configure it directly in Shopware itself. For this create a config/packages/redis.yml
file with the following content
# config/packages/redis.yml
framework:
session:
handler_id: "redis://host:port"
Symfony also provides PHP implementations of some adapters:
To use one of these handlers, you need to create a new service in the dependency injection and set the handler_id
to the service id.
Example service definition:
<service id="session.db" class="Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler">
<argument ....></argument>
</service>
Example session configuration:
# config/packages/redis.yml
framework:
session:
handler_id: "session.db"