Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 ?

share|improve this question
    
If your application doesn't actually use sessions, where are they coming from? –  Michael Hampton Mar 10 at 16:05
    
I guess it's Symfony2, or one of the bundles that creates them by default. I am going to take a look, thanks –  Nicolas Reynolds Mar 10 at 16:10

2 Answers 2

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.

share|improve this answer
    
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 at 16:14
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.