Hi guys 'n gals.. first time poster here.. Looks like a great community you have here! I have been browsing around, and have found the replies to be quite informative and friendly. I'm hoping someone could lend their expertise and helpful hand on an issue I am having. I'm slowly getting the hang of PHP, but there are still some gaps that I do not quite get yet!
I have been looking into getting a $_SESSION variable accessed from within a require_once() function..
so my main index.php starts out like such:
<?php
session_start();
if(!isset($SESSION['browser'])){
// Establish and set superglobal variable $SESSION['browser'].
$SESSION['browser'] = $SERVER['HTTP_USER_AGENT'];
}
?>
..some more page code follows...
...then, in the middle of my page, I need to require an include file:
<?php
require_once("/include/leftNav.inc.php");
?>
Over in my leftNav.inc.php page, I need to access the $_SESSION['browser'] variable to help define the outcome of my navigation panel...
<?php
if(ereg('MSIE (([0-9]).[0-9])', $_SESSION['browser'], $matches)){
// do this setup...
} else {
//do that setup instead....
}
?>
But as it stands, I get an 'Notice: Undefined variable: _SESSION... ..blah blah blah .. .' message :glare: So I was wondering.. since $SESSION variables are supposed to be global in scope, how come I cannot simply plug them into seperate require_once() include files? What is the solution to this?
Any help would be greatly appreciated!
Cheers,
NRG