[dev] Process for session creation?

Kevin M. Myer kevin_myer at iu13.org
Fri Oct 14 17:04:43 PDT 2005


Hi,

I'm trying to extend the memcache sessionHandler class to be a bit more robust
and I keep throwing an exception in Apache that takes out the child process. 
Definitely a bug in my code somewhere I have to believe, but I'm having trouble
pinpointing where, as the code is only a little bit different from what I
posted to bugs.horde.org, and that code works (or at least I should say it
doesn't crash the Apache process, which is not the same thing as saying it
works :)

So, in trying to understand this, I added some debug statements and what it
looks like is happening, generally, is:

1) Session is initialized and an id is generated.
2) The SessionHandler is called and a connection is opened to the session store
(and if its a persistent store, an existing connection is reused)
3) The SessionHandler attempts to read the value for the sessionid (presumably
to see if it already exists??)
4) If it doesn't, it writes the first sets of values to the session store.

The values in the session for the first write are:
horde_language|s:5:"en_US";hordeMessageStacks|a:2:{s:10:"javascript";a:0:{}s:6:"status";a:0:{}}

After that initial write, is when Apache dies.  My question is that the correct
process that a session creation should go through?

Also, a question about persistent connections.  The various PHP functions that
are used to close Horde SessionHandlers (eg. mysql_close and memcache_close)
don't do anything if mysql_pconnect or memcache_pconnect were called
(persistent connections are only closed on shutdown of web server).  But,
irregardless of whether a connection is persistent or not, $this->_connected is
set to false in the close function.  So when $this->_connect is called for a
persistent connection the second time, $this->_connected is false and a new
connection is opened.  I've gone around and around on whether this matters or
not, but it doesn't seem right to me.  Given the still not quite right behavior
of at least the MySQL session handler, could this be the cause of it?

I'd think it should be more like:

function close()
{
    if ($this->_connected && $this->_params['persistent'] != true) {
        $this->_connected = false;
        ...
    }
}




-- 
Kevin M. Myer
Senior Systems Administrator
Lancaster-Lebanon Intermediate Unit 13  http://www.iu13.org



More information about the dev mailing list