www/www-header.php - FIX: non-set _SESSION variables causing 'undefined index' in...
[phorkie.git] / www / www-header.php
index f381872691f67a29140c67fb6a488600e36e587c..74863e1637f18b011a31ec2609eb38105e0bbea2 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace phorkie;
+session_start();
 set_include_path(
     __DIR__ . '/../src/'
     . PATH_SEPARATOR . get_include_path()
@@ -56,12 +57,19 @@ $twig = new \Twig_Environment(
         'debug' => true
     )
 );
+//$twig->addExtension(new \Twig_Extension_Debug());
 
 function render($tplname, $vars)
 {
     $vars['css'] = $GLOBALS['phorkie']['cfg']['css'];
     $vars['title'] = $GLOBALS['phorkie']['cfg']['title'];
     $vars['topbar'] = $GLOBALS['phorkie']['cfg']['topbar'];
+    if (isset($_SESSION['identity'])) {
+        $vars['identity'] = $_SESSION['identity'];
+        $vars['name'] = $_SESSION['name'];
+        $vars['email'] = $_SESSION['email'];
+    }
+    $vars['db'] = new Database();
 
     $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
     echo $template->render($vars);
@@ -71,4 +79,4 @@ function redirect($target)
     header('Location: ' . $target);
     exit();
 }
-?>
\ No newline at end of file
+?>