MeanMrMustard Posted March 21, 2006 Share Posted March 21, 2006 I need to pass some session variables to another page via the Include_Once command.Does anyone know if this can be done and if so what the code would be? This is what I have so far and the session variables don't carry across...Start.php<?Session_Start();$Ref_Name = $_SESSION['Ref_Name'];include_once("..common/header.php");?>Header.php<?Session_Start();$Ref_Name = $_SESSION['Ref_Name'];?>Basically the Header needs the variable to dynamically create a menu to be displayed on the initial page. Quote Link to comment https://forums.phpfreaks.com/topic/5380-include_once-and-session-variables/ Share on other sites More sharing options...
azuka Posted March 21, 2006 Share Posted March 21, 2006 Ideally, you should call session_start() only once from any file. From what I see, you're restarting the session which isn't too good as you can't access it in the included file. Start it in start.php only. Quote Link to comment https://forums.phpfreaks.com/topic/5380-include_once-and-session-variables/#findComment-19213 Share on other sites More sharing options...
MeanMrMustard Posted March 21, 2006 Author Share Posted March 21, 2006 I guess that makes sense but even if I remove that session_start(); from the 2nd page the variables don't pass. If I run that Header Page by itself it picks up the variables but not via the Include_Once command. Quote Link to comment https://forums.phpfreaks.com/topic/5380-include_once-and-session-variables/#findComment-19227 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.