Skip to content

Configuring the Directory where Session Files are Saved

Warning: You are browsing the documentation for Symfony 3.x, which is no longer maintained.

Read the updated version of this page for Symfony 7.1 (the current stable version).

By default, Symfony stores session metadata on the filesystem. If you want to control this path, update the framework.session.save_path configuration key:

1
2
3
4
5
# app/config/config.yml
framework:
    session:
        handler_id: session.handler.native_file
        save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'

Storing Sessions Elsewhere (e.g. database)

You can store your session data anywhere by using the handler_id option. See Configuring Sessions and Save Handlers for a discussion of session save handlers. There are also articles about storing sessions in a relational database or a NoSQL database.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version