Configuring the Directory where Session Files are Saved

Version: 3.4
Edit this page

Warning: You are browsing the documentation for version 3.4 which is not maintained anymore.

If some of your projects are still using this version, consider upgrading.

Configuring the Directory where Session Files are Saved

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

  • YAML
  • XML
  • PHP
# app/config/config.yml
        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.