Page 1 of 1

Session, Function, Global

Posted: Fri Jul 11, 2003 1:22 am
by Gen-ik
Just a quick question..

If I wanted to use session variables in a function would I still need to use the global call ( example.. global $my_session_var; ) or are session variables global by default?


Thanks in advance.

Posted: Fri Jul 11, 2003 3:54 am
by Tubbietoeter
they are global if you call them directly ($_SESSION['var']).

if you assign them at the beginning of the script ($var=$_SESSION['var']) you still need global.

Posted: Fri Jul 11, 2003 6:57 am
by Gen-ik
So.... I guess I would need to use the global method because when I first start my sessions I do something like..
session_register("my_session_var");
$my_session_var = "some value";


..?

Posted: Fri Jul 11, 2003 8:16 am
by Tubbietoeter
i guess so but since i never use session_register i don't know for sure. just test it!!