Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Include_Once and Session Variables

Status
Not open for further replies.

dbray6714

IS-IT--Management
Jul 21, 2005
1
US
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.
 
the way that you are doing it with the include function means that the code in header.php is logically included in the start.php file. thus they will have the same variable scope as they would were the two sets of code typed into the same file.

in start.php you are assuming that the Ref_Name element is already set. i would consider debugging where that variable comes from and where it is being set. for example should the assignment be the other way around?
Code:
$_SESSION['Ref_Name'] = $Ref_Name;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top