I see there are thousands of files in my "/tmp" directory (a CentOS machine) and almost all of them are PHP session files.
I'm worried about the possible impact this might have on my system.
Are those files ever deleted either by the OS, Apache or PHP? or I have to take care of it myself?
| |||||||
feedback
|
|
They should be deleted by the PHP garbage collector. The frequency is controlled by the | |||||||||
feedback
|
|
You could setup a cron script to clean them up automatically. It's generally a good idea to test for creation date older than what the life of cookies is set up to be on your system. Limiting cookie life is done thusly (must be done before script outputs anything):
Then, in your cleanup script:
Then, in your crontab:
| |||
|
feedback
|
|
The PHP cookies get deleted at closing of the browser.But permanent cookies may be created using a database entry or a server side file as a cookie. | |||
|
feedback
|
|
This might be an old question, but no one nailed it right to the head: No, by default session files are not deleted at any point of time (at least on a php 5.3 / ubuntu/debian standard set up). php.ini says it like this:
To be honest, i'm am a little bit shocked by this ! I mean, this will cause hundreds of thousands of files ... A browser restart will mean that the user gets a new session id, so the "old one" will never be deleted. | |||
feedback
|