Jump to content

Archived

This topic is now archived and is closed to further replies.

MeanMrMustard

Include_Once and Session Variables

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.