$_SESSION in WHERE statement

$_SESSION in WHERE statement

carrarachristophecarrarachristophe Posts: 100Questions: 24Answers: 2

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

  • sasmitsasmit Posts: 5Questions: 1Answers: 1
    Answer ✓

    Have you used session_start() at the top of the page?

  • carrarachristophecarrarachristophe Posts: 100Questions: 24Answers: 2

    Yes I did, in includes/header.php.

  • carrarachristophecarrarachristophe Posts: 100Questions: 24Answers: 2

    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.

  • carrarachristophecarrarachristophe Posts: 100Questions: 24Answers: 2

    Case solved, see above

Sign In or Register to comment.