You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$_SESSION['user_id'] = 'some_value';
$phpView = new PhpRenderer("path/to/templates", ["title" => "My App"]);
$phpView->setLayout("layout.php");
//...
$phpview->render($response, "hello.php", ["title" => "Hello - My App", "name" => "John"]);
In hello.php:
<?php var_dump($_SESSION); // Will not be set ?>
Hello <?=$name?>! Your id is: <?= $_SESSION['user_id'] ?>
In layout.php:
<?php var_dump($_SESSION); // Will be filled as intended ?>
<html><head><title><?=$title?></title></head><body><?=$content?></body></html>
So, in both hello.php and layout.php you will be able to get $title var. But, in hello.php global $_SESSION var will be empty.
Expected behavior would be leaving global variables intact.
The text was updated successfully, but these errors were encountered:
How to reproduce:
In
hello.php
:In
layout.php
:So, in both
hello.php
andlayout.php
you will be able to get$title
var. But, inhello.php
global $_SESSION var will be empty.Expected behavior would be leaving global variables intact.
The text was updated successfully, but these errors were encountered: