Re: [Phplib-users] php4 session fix, and some thoughts
Brought to you by:
nhruby,
richardarcher
|
From: Joe S. <jo...@be...> - 2003-01-24 21:45:42
|
Variation on the theme:
On Thu, Jan 23, 2003 at 02:27:09PM -0600, Lindsay Haisley wrote:
>
> This would probably work (although I haven't tested it either). I think it
> would be more scalable to make keeping track of session business the
> responsibility of the Session class rather than the effective constructor
> for the Page class, but if we're going this route, and $sess->in is to be
> depreciated, the above code could be simplified further still.
>
I played around some and these solutions seem to work OK.
> I do have some concern with implications of the fact that the global name
> space must be used to reference all persistent data under php4 session
> management. I think there needs to be a naming convention established for a
> reserved global name space in phplib. For instance, we might say that all
> variables which phplib uses for its own internal record keeping must start
> with $_PHPLIB or something similar. This could be part of the published API
> so that applications could avoid tromping on internal variables. It's
> concievable, considering the above patch, that someone might write an app
> that unknowingly used the name $phplib_sess_in for a global variable.
>
Agree on your concerns for possible confusion and name collision.
Aren't session variables with the existing session3 class also global?
> This is what I was trying to do by encapsulating the auto_init flag in a
> class of its own whose objects were identified with session_id(). As I
> noted, this may be overkill. I did consider a solution as simple as the
> above patch.
>
Here's Gian's suggestion with session appended to the variable name.
Seems sess->get_id() really is an internal method. Couldn't get it to
work using it.
$phplib_sess = "phplib_".$sess->id;
if(array_key_exists($phplib_sess, $_GLOBALS)) {
$sess->in = 1;
}
## Load the auto_init-File, if one is specified.
if (($sess->auto_init != "") && !$sess->in) {
$sess->in = 1;
$GLOBALS[$phplib_sess]['id'] = $sess->id;
$sess->register($phplib_sess);
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();
}
}
Joe
> --
> Lindsay Haisley | "Everything works | PGP public key
> FMP Computer Services | if you let it" | available at
> 512-259-1190 | (The Roadie) | <http://www.fmp.com/pubkeys>
> http://www.fmp.com | |
|