Stupid globals vars<

liunx

Guest
I have a problem with some of my globals vars, they don't want to keep their values from pages to pages.

I do this in a page after the user logon to keep a tarce of is username: $GLOBALS['User'] = $_POST["User"];

after, i include a file that set a cookie and redirect me to another page. And it's in this other page that i try to get the value of the global var like this: echo "<p class=\"MainFont\" align=\"center\">global:".$GLOBALS['User']."</p>";

Any idea, why the gloval is empty when i get to this page?An associative array containing references to all variables which are currently defined in the global scope of the script.
it has to be set on every page.

you should be using sessions for this anywayUse php_include();furry guru is right..use $_SESSION to maintain the variable across pages...globals are for that current page onlyI'll do that.

But, just to be a little more intelligent, how did i manage to pass a global var directly between two files?

and btw, cool new icon scouttyou didn't..you wouldeve had to POST,GET or otherwise transfer it to the other page...or include the global into the page from another file using include() or require();yeah, used a include.

That's good to know it work with this.you can't submit a form variable to a file you include, well you can but once you goto another page you loose the variable.

the only way to pass a global to all pages it to "define" it in the included file. so it will be always set no matter what page you are on.

and thanks, :)
 
Back
Top