Hello all,

I've been having an issue with php variables recently. I don't have much experience working with sessions, but I know that domain.com and www.domain.com are viewed differently when working with sessions. The problem I have is with included files. I am calling .../logbook/header.php from ...logbook/Graphs/index.php. When I use include_once('header.php') from files within logbook/, I am able to use the session variables, but when I include the full path in the include_once() command, I can't access the session. How can I set the session so that it is accessible to both 'header.php' and '.../full path/header.php'?

ensure the full path is correct

Do you mean in the include_once() command or when I set the session? It's correct in the include command, and I don't know how to set it explicitly when I set sessions.

session_start();

// set session
$_SESSION['your_session_name'] = "your_value";

// read session
$_SESSION['your_session_name'];

No, my session is set. I can echo my session id in the logbook/Graphs/index.php page, but not from header.php when it's included from logbook/Graphs/index.php.

well that's weird, maybe you haven't included the header.php correctly in the index.php, because if you include it right the header.php becomes part of the index.php, try echoing or alerting text in header.php, to test if is really included

I know it's odd. It's most definitely included. It's my header file with my navigation menu. I include it on every page. If I include

session_start();echo session_id();

in header.php it echoes the same session id on all the pages except when it's included from a file located in a subfolder.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.