0

I'm looking for a way to disable the file saving of PHP sessions. (I do not need sessions in my application)

I tried to set save_path = NULL, but it only set it to the default path (/tmp).

Is there a way to do that ? Or maybe I shouldn't do it at all for reasons I ignore ?

Nicolas Reynolds
  • 177
  • 1
  • 1
  • 8

2 Answers2

1

PHP should only be creating session files is session_start() is called in your application (meaning it needs them) or PHP is configured to always start sessions.

Make sure session.auto_start = 0 is set in your php.ini so that the sessions are not started automatically

Once that's set if you aren't creating sessions then your save path shouldn't matter at all.

DorianFM
  • 191
  • 3
  • If you _really_ wanted to disable sessions you could also create a current `session_set_save_handler()` which called empty functions, hence doing nothing. – DorianFM Mar 10 '14 at 16:14
1

I solved my problem. I disabled the saving of session in Symfony2 directly, by adding stateless to the app/config/security.yml file :

firewalls:
    api:
        stateless: true
        pattern: ^/
        http_basic:
            realm: "Authentification needed"

This way the sessions are used but not stored in files.

Nicolas Reynolds
  • 177
  • 1
  • 1
  • 8