PHP session not working

Hey hey,

I am working on something and have to use PHP sessions for that. The clue was, when clicking visiting a site, let's say, an ID gets saved within a session. This works. But when I am going to and echo the ID which got stored on, it just does not work. So a variable gets set on /page and when the user gets redirected to /page/subpage the variable should be readable/transferred from /page to /page/subpage.

My layout.html looks like that:

<?php session_start();?>
<!DOCTYPE html>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">

Here is my partial.html, which is properly parsed within a template which is for

{{ if type == "partial" }}
        $_SESSION["pID"] = $p->id;
        echo $_SESSION["pID"]; // This works nice and sturdy, so this session variable was saved
{{ /if }}

And here is my template.html for (PHP session should already got started by layout.html)

    echo $_SESSION["pID"]; // DOES NOT WORK

In this very case the error is: ErrorException in Parser.php(1235) : eval()'d code line 3: Undefined index: pID

So it seems that the variable wasn't got saved in the session or the session wasn't saved.

I just don't know what to do on that one, hope one of you guys could help me out.

Cheers Max

Answered by Erin Dalzell!
>>>>>>> Answered <<<<<<<
7 Replies