You are here: Re: Garbage collector problem with sessions « PHP Programming Language « IT news, forums, messages
Re: Garbage collector problem with sessions

Posted by deciacco on 09/06/07 22:31

What I found with the UPDATED code, is that the GC does indeed delete
session files, but it does not delete the file associated with the
current session. In other words...

Imagine the script running in two different browsers, browser A and
browser B. In bA you continually refresh so not to let the session
expire. In bB you let the session expire by not touching it for more
than, in this case, 10 seconds. When you refresh bB after 10 seconds
you'll see that the session restarts because the GC from bA has deleted
the session file of bB. If you didn't have bA running, the session in bB
would just continue.

This is fine in an enviroment with many hits, but in an app that only
has one user or one user at any given time, it does not work.

I tried writing a custom session handler with a database, but this
yielded the same results. What I ended up using is basically my own GC
script. The script deletes "expired" session files manually and I set it
to run before every session_start(). This seemed to work just fine. I
could have even gone as far as putting in probability, but since this is
really a few-user app at most, it doesn't really matter.

I am curious to know more about your php configuration on Windows.
What version of Windows/Php, Cgi or Asapi, etc, etc.

I used these instructions to setup php on my win 2k3 server.
http://www.peterguy.com/php/install_IIS6.html

For what it's worth, I've tested this on another Windows box with the
same setup and I get the same results, so this leads me to believe that
it's something wrong with the way I'm setting up php, or perhaps a bug
in Php in Windows.

Vladimir Ghetau wrote:
> On Sep 4, 8:00 pm, deciacco <a@a> wrote:
>> Still does not work. Below is the updated code. (This is the Windows
>> code. The linux code just changes the slashes) I can see the session
>> ....
>
> The thing is, I tried your code and it worked after I made those
> changes on my local windows box, that's how I came with the
> suggestions.
>
> I think you should try things like:
>
> - setting the ini settings directly in php.ini
> - do more debugging, step by step (e.g. try the sessions without
> setting a particular path, use default one; next thing would be trying
> to see what happens if 'session.gc_maxlifetime' is not set and so on);
> - when doing an ini_set, try an ini_get and see if the value is really
> set
>
>
> This is what I would do, the code is cool as it is now
>
> Best!
>
> Vladimir Ghetau
>
> ------------------------------
> http://www.vladimirated.com
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация