Re: Sessions
| From: | Dan Joseph | Date: | Mon, 15 Sep 2008 17:10:12 +0000 |
| Subject: | Re: Sessions | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280198@lists.php.net to get a copy of this message | ||
On Mon, Sep 15, 2008 at 1:06 PM, Stut <stuttle@gmail.com> wrote:
> On 15 Sep 2008, at 17:14, Thodoris wrote:
>
>> Thanks I have already started working on that. I suppose that I should run
>>>> the garbage collector every now and then to see if the session has expired.
>>>> I guess this is the basic difference between the normal sessions and
>>>> database oriented. The fact that you need to create a way to check the
>>>> sessions that are expiring.
>>>>
>>>
>>> Not at all. The garbage collector is run by the session extension
>>> according to rules set out in php.ini. It does it for you. Doesn't matter
>>> whether it's OO or not.
>>>
>>> -Stut
>>>
>>> You're right I've noticed that every time you run session_start or it's
>> done automatically (if you set session.auto_start) then gc is also running.
>> In case you have defined a custom function using session_set_save_handler
>> then it runs this function instead of the built-in that cleans the database
>> of the unneeded expired sessions.
>>
>> Do I get this right or there is something that I am missing?
>>
>
> Not quite. The rules around when the garbage collector is run are not that
> simple, but in most cases you don't need to worry about it. Implement the
> handler and you can rest assured that it will be called as often as the
> default session GC would be called. You can optionally take the lifetime
> parameter it gets passed into account but I personally don't.
>
> -Stut
>
> --
> http://stut.net/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Stut, something I noticed you do is run the GC 10% of the time. I am
currently running mine with the session.gc_probability = 50. Do you find
that 10% is enough? Or was that really just for example?
--
-Dan Joseph
www.canishosting.com - Plans start @ $1.99/month.
"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."