Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Mar 2002
    Thanked 19 Times in 18 Posts

    How does PHP handle session files cleanup?

    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.
    - George
    - JavaScript Kit- JavaScript tutorials and 400+ scripts!
    - JavaScript Reference- JavaScript reference you can relate to.

  2. #2
    Super Moderator
    Join Date
    May 2002
    Perth Australia
    Thanked 110 Times in 108 Posts
    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 ....'
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  3. #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Marion, IA USA
    Thanked 84 Times in 83 Posts
    And you can view all this information easily if you create a php file and put this in it:




    Which will produce this:


    And you can look in the session section to see what everything is set to.
    CodingForums Supreme Overlord
    All Hail Spookster

  4. #4
    Regular Coder
    Join Date
    Jul 2002
    Thanked 0 Times in 0 Posts
    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.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts