Reteriving Global variable.

A

Anonymous

Guest
I am using the following to create a global variable:

seesion_start();
$_SESSION['xyz']="xyz";

in the beginning of a page. How can I retrieve and work with xyz variable in next page? Will

print $xyz;

work? Thanks
 
popeye said:
I am using the following to create a global variable:

seesion_start();
$_SESSION['xyz']="xyz";

in the beginning of a page. How can I retrieve and work with xyz variable in next page? Will

print $xyz;

work? Thanks

What you're thinking of is a Session Variable. A Global Variable is something completely different. And no, that won't work. You need to have session_start() on both pages, and then you will both read from and write to $_SESSION['xyz'].
 
Ok. How would you create and use a global variable that can be changed and used on different pages. Give me an example.
Thanks.
 
I'm only going to say it one more time: Session Variable. Not Global Variable. Session. Go it? Okay.

Now then, the best example in the world can be found in the documentation in the Sessions page. Check it out.
 
In the true sense, If you want a global var, like an application var in ASP, you need to write it somewhere, like a file or something like that
 
After I put all your lukewarm tips together, I got it right and now I am up and running. I guess there is no freebees which is OK with me.
Thanks all.
:grin:
 
Back
Top