Re: [Phplib-users] php4 session fix, and some thoughts
Brought to you by:
nhruby,
richardarcher
From: Joe S. <joe...@us...> - 2003-01-23 19:38:17
|
On Thu, Jan 23, 2003 at 06:11:14PM +0100, Giancarlo wrote: > Is this too semple? untested. > maybe one should use $_SESSION instead of $GLOBALS. > FWIW this is more in line with what I had started myself. Max - I understand not supporting the sess->in in the original release of session4. However I think that supporting sess->auto_init is pretty important and as has been shown can be done with little overhead. It is important to provide backward compatibility to phplib applications for now. This is getting to be a soapbox issue and is turning people off from php and Zend. Many applications are not custom built but instead distributed to be used on many different servers. The documentation specifies how the auto_init should work. It does not mention the sess->in that I could find. So I'm much less concerned about using sess->in to accomplish the loading-once-per-session of the auto_init file. Gian - it looks like you also applied the patch to allow a path for the auto_init file. thanks. This is a shortcoming of the session3 code. thanks, Joe > ## Load the auto_init-File, if one is specified. > $sess->register('phplib_sess_in'); #1 > if ($GLOBALS['phplib_sess_in'] == 1) { #2 > $sess->in =1; #3 > } #4 > if (($sess->auto_init != "") && !$sess->in) { > $sess->in = 1; > $GLOBALS['phplib_sess_in'] = 1; #5 > if (substr($sess->auto_init,0,1) == '/') > include($sess->auto_init); > else > include($_PHPLIB["libdir"] . $sess->auto_init); > if ($sess->secure_auto_init != "") { > $sess->freeze(); > } > } > > > > > > ------------------------------------------------------------------------ > > > > --- session4.inc 2003-01-20 18:52:26.000000000 -0600 > > +++ session4.inc.fixed 2003-01-20 18:53:27.000000000 -0600 > > @@ -11,6 +11,19 @@ > > * @access public > > * @package PHPLib > > */ > > + > > +class CurrentSession { > > + var $ai_done = false; > > + > > + function set_ai_done($val) { > > + $this->ai_done = $val; > > + } > > + > > + function get_ai_done() { > > + return $this->ai_done; > > + } > > +} > > + > > class Session { > > > > > > @@ -43,8 +56,8 @@ > > * Marker: Did we already include the autoinit file? > > * > > * @var boolean > > - */ > > - var $in = false; > > + */ > > +# var $in = false; > > > > > > /** > > @@ -147,6 +160,20 @@ > > * > > * @see name() > > */ > > + > > + function get_auto_init_done() { > > + $sob = "sob_".session_id(); > > + global $$sob; > > + return $$sob->get_ai_done(); > > + } > > + > > + function set_auto_init_done($val) { > > + $sob = "sob_".session_id(); > > + global $$sob; > > + $$sob = $_SESSION[$sob]; > > + $$sob->set_ai_done($val); > > + } > > + > > function Session() { > > $this->name($this->name); > > } // end constructor > > @@ -170,6 +197,14 @@ > > > > $ok = session_start(); > > $this->id = session_id(); > > + > > + if (!isset($_SESSION["sob_".session_id()])) { > > + $sob = "sob_".session_id(); > > + global $$sob; > > + $$sob = new CurrentSession; > > + $this->register($sob); > > + } > > + > > > > // If register_globals is off -> restore session variables to > global scope > > if(!(bool) ini_get('register_globals')) { > > > > > > ------------------------------------------------------------------------ > > > > --- page4.inc 2003-01-20 17:21:23.000000000 -0600 > > +++ page4.inc.fixed 2003-01-20 17:37:24.000000000 -0600 > > @@ -51,8 +51,8 @@ > > } > > > > ## Load the auto_init-File, if one is specified. > > - if (($sess->auto_init != "") && !$sess->in) { > > - $sess->in = 1; > > + if (($sess->auto_init != "") && !$sess->get_auto_init_done()) { > > + $sess->set_auto_init_done(1); > > include($_PHPLIB["libdir"] . $sess->auto_init); > > if ($sess->secure_auto_init != "") { > > $sess->freeze(); > > > > > > ------------------------------------------------------- > This SF.NET email is sponsored by: > SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! > http://www.vasoftware.com > _______________________________________________ > Phplib-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phplib-users |