DarkPrince2005 Posted August 3, 2009 Share Posted August 3, 2009 Ok, strangee and stupid question regarding global variables... if i declare a the country of a user as a global variable when he logs in, will it be stored in the system memory or something for the duration of his session. And will it then be available even though he'll be navigating back and forth between different pages? Link to comment https://forums.phpfreaks.com/topic/168587-solved-global/ Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 You can use constants.... http://us2.php.net/manual/en/function.constant.php Link to comment https://forums.phpfreaks.com/topic/168587-solved-global/#findComment-889249 Share on other sites More sharing options...
JonathanV Posted August 3, 2009 Share Posted August 3, 2009 No, making a variable a global variable only makes it availlable in the functions you're using it in your application, it won't make it availlable on other pages. Technically speaking it does save the variable somewhere in the memory because that's what happens when you declare a variable ... but not in the way you're asking for. If you want to save some information from a user during his visit you can just save it in the session ... pretty logical ain't it ? $_SESSION["country"] = "Belgium in my case ..."; I hope this gets you on your way ... Link to comment https://forums.phpfreaks.com/topic/168587-solved-global/#findComment-889256 Share on other sites More sharing options...
roopurt18 Posted August 3, 2009 Share Posted August 3, 2009 And don't forget to call session_start()! Link to comment https://forums.phpfreaks.com/topic/168587-solved-global/#findComment-889285 Share on other sites More sharing options...
JonathanV Posted August 3, 2009 Share Posted August 3, 2009 And don't forget to call session_start()! Indeed, nice remark! Link to comment https://forums.phpfreaks.com/topic/168587-solved-global/#findComment-889287 Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 edit: wrong thread Link to comment https://forums.phpfreaks.com/topic/168587-solved-global/#findComment-889307 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.