$_SESSION in WHERE statement
$_SESSION in WHERE statement
Error messages shown: Undefined variable: _SESSION...
Description of problem:
Hello,
I am trying to add some $_SESSION information to a WHERE statement using:
Editor::inst( $db, 'bibliotheque_bibliotheques', 'bibliotheque_id' )
->fields(
.........
->where( 'utilisateurs.utilisateur', $_SESSION['username'] )
->debug( true )
->process( $_POST )
->json();
I am getting the following error message: Undefined variable: _SESSION...
I know the rest of the code is correct because:
1. when I replace $_SESSION['username'] by an existing value it works fine
2. When I remove that part, the $_SESSION['username'] appears fine outside of the datatable, through:
<?php include("includes/header.php"); ?>
How can I define $_SESSION['username'] in the php?
Thanks and regards,
Christophe
This question has an accepted answers - jump to answer
Answers
Have you used session_start() at the top of the page?
Yes I did, in includes/header.php.
You are right,
Although my html page loads header.php, which includes session_start(), I needed to add it again in my php file.
I don't understand why.
Case solved, see above