On 3 Apr 2003 CPT John W. Holmes wrote:

> No, $varname isn't created. You don't need it. You have a variable called
> $_SESSION['varname'], just use that where ever you need it (even within
> functions). If register_globals is on, you should be using the
> session_register() method, anyhow, not the one above.

I have register_globals off as that is (as I udnerstand it) a more 
secure approach.  ANd it will make hte code messy to use 
$_SESSION['varname'] everywhere.  I think I'll just copy it to a global 
and use it that way.

Which leads to another question ... I thought these two constructs were 
equivalent:

        $var = "foo";
        session_register('var');
        .....
        $var = "bar";

        $var = "foo";
        $_SESSION['var'] = $var;
        .....
        $var = "bar";

I would have thought that in both cases the session data saved at the 
end of the script will have $var set to "bar", i.e. it is the value at 
the end of the script, not the value at time of registration, that is 
saved.  Is this incorrect?  The docs for session_register() left me 
with this impression, and the general session docs suggest that 
registering a variable with $_SESSION is equivalent to doing it with 
session_register(), and in fact preferable.  If they behave 
differently, I can't see where the docs say so.

Thanks,

 ----------
 Tom Rawson




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to