title: PHP when to remove session flash message
body: <p>I have my own MVC and in my <code>BaseController</code> i create simple method <code>flashMessage</code>.</p>
  
  <pre><code>public function flashMessage($name, $value)
  {
      if(!isset($_SESSION['message'][$name])) {
          $_SESSION['message'][$name] = $value;
      }
  }
  </code></pre>
  
  <p>This work good but i dont know when to destroy this session. Is good idea to put in <code>__destructor</code> <code>session_unset($_SESSION['message']);</code> ?</p>
  
  <p>This work good but my message has no lifetime</p>
  
  <pre><code>    public function authenticate()
      {
  
          if(isset($_POST['submit']))
          {
              $username = $this-&gt;inputFilter($_POST['username']);
              $password = $this-&gt;inputFilter($_POST['password']);
  
              // check if user exist
              if(!$this-&gt;auth-&gt;autheticate($username, $password)) {
                  $this-&gt;flashMessage('error', 'Error: Invalid username or password!');
  
                  return $this-&gt;redirect('login');
              }else {
                  $this-&gt;flashMessage('success', 'Success: Uspešno ste se prijavili na sistem!');
                  return $this-&gt;redirect('home');
              }
  
           }
      }
  </code></pre>