3

I am new to symfony and am responsible for a site that I didn't build. For some reason the site is on a live server but running in dev mode. - Im not sure why??

That aside - The website keeps writing _sess files to my /tmp directory. The contents of each _sess file is exactly the same. See below:

_symfony2|a:3:{s:10:"attributes";a:0:{}s:7:"flashes";a:0:{}s:6:"locale";s:2:"en";}

Do I really need all of these files? Can anyone suggest a way of disabling this feature?

Thanks in advance

j0k
  • 22,600
  • 28
  • 79
  • 90
Bob Flemming
  • 466
  • 3
  • 9
  • 21
  • I don't think this is a normal behavior, I think this is a feature designed in the project (and not from Symfony2 itself), perhaps a listener ? Or perhaps a monitoring software installed on your machine which log sessions (_sess) in tmp ? – Sybio Jun 03 '13 at 11:57
  • Well if you look at encoded the data within the _sess file (posted above) it contains the string: '_symfony2', so it must be generated by the symfony2 website. Can you suggest a way of preventing this from happening? – Bob Flemming Jun 03 '13 at 13:22

2 Answers2

0

The default session storage of Symfony2 writes the session information to file(s). The location these files are written to is determined by the config parameter framework.session.save_path. The default value for this is %kernel.cache.dir%/sessions. This means that in a default installation of symfony the session files would be written to the cache directory for the environment.

However, this can be a problem as the cache directory has to be cleared each time an app is deployed, thus logging all the users out. Therefore presumably your app has been configured (most likely in config.yml) to store the session files in /tmp.

As I understand it, sessions that have expired should be garbage-collected at some point. Symfony also has some config params that affect this - see the FrameworkBundle Configuration. I don't know how much traffic your website has but obviously you do need the session files for active sessions. If you think you have a lot of expired sessions you could try tweaking the gc config params.

Alternatively, if having the session files in /tmp is specifically the problem you could relocate them (by changing the value of the framework.session.save_path) or use PDOSessionHandler to store sessions in the database.

redbirdo
  • 4,937
  • 1
  • 30
  • 34
0

I have this problem with symfony 1.4.20 on a web site I inherited. It is writing files to

/var/lib/php/sessions

every second, until the server runs out of iNodes. I've tried changing settings in settings.yml. app.yml and PHP session variables. Nothing sees to be working though, the only way I can stop it is to change the ownership of /var/lib/php/sessions to root and that prevents any session files being created.

Grindlay
  • 571
  • 5
  • 8