0

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'?

2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by grant.baker
0

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.

-1
session_start();

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

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

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.

0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.