ghostta Posted May 14, 2010 Share Posted May 14, 2010 When people log into my site by clicking submit, they are passed to a authenitcation page which if they pass directs them to the internal site. What I would like to do is have a few variables that are global across all the logged in pages they access like their company logo and name. How do I do this? I tried $GLOBALS['xxx'] but it doesn't seem to stick beyond the page they are assigned. Link to comment https://forums.phpfreaks.com/topic/201758-variables/ Share on other sites More sharing options...
Mchl Posted May 14, 2010 Share Posted May 14, 2010 http://php.net/manual/en/features.sessions.php Link to comment https://forums.phpfreaks.com/topic/201758-variables/#findComment-1058303 Share on other sites More sharing options...
ghostta Posted May 14, 2010 Author Share Posted May 14, 2010 Ya, I thought about sessions. But the other problem I had with sessions is the across all the pages I could access my session variables like $_SESSION['xxx'] but if I tested for the session id like session_id() == "" that would always come back true. Is it possible to have sesssion_id() return an empty string but still access $_SESSION['xxx']? I was worried there was an underlying bigger problem that would affect me down the road. Link to comment https://forums.phpfreaks.com/topic/201758-variables/#findComment-1058314 Share on other sites More sharing options...
Mchl Posted May 14, 2010 Share Posted May 14, 2010 Did you test session_id() before or after session_start() ? Link to comment https://forums.phpfreaks.com/topic/201758-variables/#findComment-1058320 Share on other sites More sharing options...
ghostta Posted May 14, 2010 Author Share Posted May 14, 2010 I had two function that did it for me. The auth page would call the function that would start the sesssion and register the vars. The page it directed you to would then call the check function which would do: if ( session_id() == "" ) But that would always result in true. Link to comment https://forums.phpfreaks.com/topic/201758-variables/#findComment-1058322 Share on other sites More sharing options...
Mchl Posted May 14, 2010 Share Posted May 14, 2010 You need to start session on every page that will use session variables. Link to comment https://forums.phpfreaks.com/topic/201758-variables/#findComment-1058399 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.