title: Set $_SESSION into input value using Twig
body: <p>I am making a registration form and I want the page to be reset in case of incorrectly entered data, but I don't want also to disappear the entered data. The problem is I don't know how to do this using Twig. So I do something like this:</p>
  
  <pre><code>$_SESSION['fr_firstName'] = $firstName;
  </code></pre>
  
  <p>And then I want to enter this name inside the input value. In my index.php I have:</p>
  
  <pre><code>&lt;?php
      session_start();
  
      require_once 'lib/Twig/Autoloader.php';
      Twig_Autoloader::register();
  
      $loader = new Twig_Loader_Filesystem('temp');
      $twig = new Twig_Environment($loader);
  
      if(isset($_SESSION['fr_firstName']))
      {
  
      }
  
      echo $twig-&gt;render('index.html', array(
          'fr_firstName' =&gt; ''
      ));
  ?&gt;
  </code></pre>
  
  <p>In my index.html is:</p>
  
  <pre><code>&lt;form action="register.php" method="post"&gt;
  &lt;input type="text" placeholder="First Name" value="{{ fr_firstName }}"&gt;
  &lt;input type="submit" class="reg" value="Sign Up"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And in my register.php is:</p>
  
  <pre><code>&lt;?php
      session_start();
      $firstName = $_POST['firstName'];
      //another thinks
      $_SESSION['fr_firstName'] = $firstName;
      //another thinks
      require_once "connect.php";
      //another thinks
      $connection = new mysqli($host, $db_user, $db_password, $db_name);
      //another thinks
      header('Location: index.php');
      //another thinks
  </code></pre>
  
  <p>ok and here is my question. How to set (in index.php) $_SESSION['fr_firstName'] into input value in index.html?</p>
  
  <p>I mean something like this:</p>
  
  <pre><code>if(isset($_SESSION['fr_firstName']))
  {
  echo $twig-&gt;render('index.html', array(
          'fr_firstName' =&gt; $_SESSION['fr_firstName']
      ));
  }
  </code></pre>