title: how to i print session on view page in zend framework
body: <p>I am very new to zend framework, and going to add session in my small application but i dont know how to print session variable to my header.phtml page. </p>
  
  <p><strong>UsersTable.php</strong></p>
  
  <pre><code>public function fetchbyWhere($where) {
           $rowset = $this-&gt;tableGateway-&gt;select($where);
           $row = $rowset-&gt;current();
           if (!$row) {
              return;
           }
           return $row;
      }
  </code></pre>
  
  <p><strong>IndexController.php</strong></p>
  
  <pre><code>&lt;?php
  
  namespace Application\Controller;
  
  use Zend\Mvc\Controller\AbstractActionController;
  use Zend\View\Model\ViewModel;
  use Application\Model\Users;          // &lt;-- Add this import
  use Zend\Session\Container; // We need this when using sessions
  
  class IndexController extends AbstractActionController {
  
      protected $usersTable;
  
      public function getUsersTable() {
          if (!$this-&gt;usersTable) {
              $sm = $this-&gt;getServiceLocator();
              $this-&gt;usersTable = $sm-&gt;get('Application\Model\UsersTable');
          }
          return $this-&gt;usersTable;
      }
  
      public function indexAction() {
          $request = $this-&gt;getRequest();
          if ($request-&gt;isPost()) {
              $user = $request-&gt;getPost('txtuser');
              $pass = $request-&gt;getPost('txtpassword');
  
              $wher = array('username' =&gt; $user, 'password' =&gt; $pass);
              $resultSet = $this-&gt;getUsersTable()-&gt;fetchbyWhere($wher);
  
              //var_dump($resultSet);
  
              if($resultSet)
              {
                  $user_session = new Container('user');
                  $user_session-&gt;ses_user = $resultSet-&gt;username;
                  return new ViewModel(array(
                      'msg' =&gt; 'valid user',
                      'sesuser' =&gt; $user_session-&gt;ses_user,
                  ));
              }
              else {
                  return new ViewModel(array(
                      'msg' =&gt; 'not a valid user',
                  ));
              }
  
          } else {
              return new ViewModel();
          }
      }
  
  }
  </code></pre>
  
  <p>now i dont know how to print this session on header.phtml page.</p>