title: How can manage errors professionally to my users
body: <p>I am writing a custom cms for personal stuff and to use in my future projects. One thing is getting into my nerves: error handling. I use sessions to show the use errors such as invalid email, you are not logged in.</p>
  
  <pre><code>$as_errmsg_arr[] = "Either your username or password is wrong.";
  $as_errflag = true;
  $_SESSION['AS_ERRMSG_ARR'] = $as_errmsg_arr;
  </code></pre>
  
  <p>then when displaying the eror I decode the error so as to show to the user like this:</p>
  
  <pre><code>if( isset($_SESSION['AS_ERRMSG_ARR']) &amp;&amp; is_array($_SESSION['AS_ERRMSG_ARR']) &amp;&amp; count($_SESSION['AS_ERRMSG_ARR']) &gt;0 ) 
  { 
      echo '&lt;p class="err_msg"&gt;';                             
          foreach($_SESSION['AS_ERRMSG_ARR'] as $as_error_msg) echo $as_error_msg.'&lt;br&gt;';
      echo '&lt;/p&gt;';
      unset($_SESSION['AS_ERRMSG_ARR']);
  }
  </code></pre>
  
  <p>this was working well before but now as my project is getting bigger it fails terrible yet it is very crucial. when I remove the line:</p>
  
  <blockquote>
    <p>unset($_SESSION['AS_ERRMSG_ARR']);</p>
  </blockquote>
  
  <p>the error generated is shown. I would appreciate some explanation and even direction on how I can solve this issue.</p>