PDA

View Full Version : How does PHP handle session files cleanup?


WA
12-08-2002, 12:41 PM
Hi:
I was wondering if anyone knew how PHP by default handles the cleanup of session files created on the server as a result of using the feature. Can I assume it will always be deleted periodically, or do I have to configure PHP to do so?

I hate to have a folder full of "garbage" files after some time due to using sessions.

firepages
12-08-2002, 01:00 PM
The frequency of garbage collection is set in the PHP.ini , you can override the session parameters by using ini_set() , but unless you have a particular need I would suggest you leave as per default settings.

You can also create your own session handler using a DB etc , OTT for most scenarios though & with a performance hit.
... if you have a real busy site you can up the session.gc_probability via ini_set() but that too could affect performance.

I think its a case of 'If it aint broke ....' ;)

Spookster
12-08-2002, 04:43 PM
And you can view all this information easily if you create a php file and put this in it:

<?php

phpinfo();

?>

Which will produce this:

http://www.designqueue.com/phpinfo.php

And you can look in the session section to see what everything is set to.

ConfusedOfLife
12-08-2002, 09:38 PM
You can also create your own session handler using a DB etc , OTT for most scenarios though & with a performance hit.


Well, if I could have a unique value for any user comming to my site, I could have entered that into my DB and then querying it based on that value, but how can I do that for different visitors if I can not recognize who is who, or better to say not using their own computer ( cookies) and some automatic server properties to do it?
I read that somewhere else also, I mean using your DB instead of a session, but couldn't find out how. I don't wana use their IP as their recognizer coz as you know you can disconnect while viewing a page and then log on! It's not also unique.

Thanx