jagguy Posted July 12, 2007 Share Posted July 12, 2007 Hi, I want to have a variable set in 1 script that can be used in all other scripts eg a global variable. I need a global variable to tell me if someone has logged in from every page and the url the site is located on for header redirects. I don't understand $GLOBAL and i tried $my_var="http://dog"; global $my_var; and echo $my_var in another script as it fails. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted July 12, 2007 Share Posted July 12, 2007 the global command is used to grab variables that are outside, for example, a function. to make it global you could use the $_SESSION global and then have session_start() at the top of each page. session_start(); $_SESSION['my_var'] = "http://dog"; echo $_SESSION['my_var']; read up about sessions... Quote Link to comment Share on other sites More sharing options...
trq Posted July 12, 2007 Share Posted July 12, 2007 The $GLOBAL array holds a list of all variables within the current scripts scope. there is no such thing as a site wide $GLOBAL. As has been posted, its sessions your looking for. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.