Re: Quick session var ?

From: Date: Thu, 08 May 2003 23:46:00 +0000
Subject: Re: Quick session var ?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146946@lists.php.net to get a copy of this message
To clarify, All session vars are currently available in both the $HTTP_SESSION_VARS and $_SESSION arrays. Whilst $HTTP_SESSION_VARS is deprecated, it still works. So, regardless of whether register globals is on or off, you can always refer to the session vars through these arrays. $_SESSION is only available as of 4.1, so the simple answer to your problem (IF you want to remain fully backward compatible) is to continue using the $HTTP_SESSION_VARS array. This rules out using the $_SESSION array at all, and means you still need to use session_register(). I'd be a little concerned here that you're placing a higher priority on backward compatibility rather than forward compatibility, since $HTTP_SESSION_VARS is deprecated, and may disappear from a future version of PHP. If you're looking for a solution which uses $_SESSION where possible, and $HTTP_SESSION_VARS where not possible, then I think you're in for a lot of work, although I haven't thought about it all too much :) The only hint I can give you without typing for another 10 minutes is to look at phpversion() :) Justin on 09/05/03 3:13 AM, Shawn McKenzie (nospam@mckenzies.net) wrote: > I am just starting to learn sessions in PHP and have a quick question (yes I > have read all of the relevent docs but am still confused on several points). > > My goal is to write a script that is usable in newer and older vers of PHP > wheteher register_globals is on or off. > > session_register() puts a $var in the session and if register_globals=on it > will be extracted and available as $var on the next page after > session_start? if register_globals=off it will be available via > $HTTP_SESSION_VARS? > > With register_globals=off on newer PHP versions I should use $_SESSION to > set and get session $vars? With register_globals=on the $vars from > $_SESSION are extracted? > > Any pointers on what would be a flexible way to handle sessions regardless > of PHP version or register_globals would be very helpfull. > > Thanks! > Shawn > > > >

« previous php.general (#146946) next »