Jump to content


Photo

Include_Once and Session Variables


  • Please log in to reply
2 replies to this topic

#1 MeanMrMustard

MeanMrMustard
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 21 March 2006 - 01:14 AM

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.

#2 azuka

azuka
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts
  • LocationNigeria

Posted 21 March 2006 - 02:51 AM

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.
Given enough eyeballs all bugs are shallow. My Website

#3 MeanMrMustard

MeanMrMustard
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 21 March 2006 - 04:24 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users