Garbage Collection Help Needed! :(

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pj
Forum Newbie
Posts: 2
Joined: Thu Mar 06, 2003 9:55 am
Contact:

Garbage Collection Help Needed! :(

Post by pj »

Hello everyone,
when I first installed PHP on my server, i set the 'session.auto_start=' definition to 1.
Now I have the following problem.... Each *.php page after refresh creates a new '0' (zero) size session file, and seems, that the garbage collector does not clean them.
How to deal with it?
Any ideas are apreciated!
10x in advance.
pj
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

garbage collection is really something else, and generally not needed in PHP scripts, although the PHP website also refers to "session data cleaning" as garbage collection as well..

.. if you enabled auto-session I believe that is the same as a session_start() for all pages, so your session-dir will fill up with some amount of files, according to http://www.php.net/manual/en/ref.session.php PHP will use the session.gc_maxlifetime setting as lifetime of session data, if this is set high your files will stay there for a while and probably pile up on busy sites.. The manual also notes that the filesystem must keep track of access-time, and some Bill Gates file systems doesn't, so if you are on windows that may be the reason..
pj
Forum Newbie
Posts: 2
Joined: Thu Mar 06, 2003 9:55 am
Contact:

Post by pj »

Hi Stoker,
Thanks for the prompt reply!

Well, I'm on Linux Slackware and PHP4. I do use session.auto_start rather than putting on each separate page session_start() in order to save some coding time. The point is, that when User is logged and after that logged out the session containing the 'user data' is removed from the file system, but those sessions with no data at all continue to stay. I presume when the site is ready it will be quite busy and I will find my self in situation of permanent "garbage collection". This is what I need to avoid. The '0' size files are those I need to remove from the system.

Thanks again.
BRGDS.
pj
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

I am guessing that when a user logs out you use a session_destroy() or similar and that will delete the session file, while thos that where never logged in still have a session so they never get a session_destroy, and those files will live as long as the timeout is set..
Post Reply