PHP when are $_SESSION vars evaluated?
<p>So my issue is that I'm setting a message in a session var to carry over in a page redirect.
And then setting the var to an empty string so it doesn't redisplay everytime.
Like so:</p>

<pre><code>if ($successMsgs || !empty($_SESSION['msg_success'])) {
 $success_block[] = '&lt;ul id="success-block"&gt;';
 foreach($successMsgs as $success) {
  $success_block[] = '&lt;li&gt;'.$success.'&lt;/li&gt;';
 }
 if (!empty($_SESSION['msg_success'])) {
  $success_block[]='&lt;li&gt;'.$_SESSION['msg_success'].'&lt;/li&gt;';
  $_SESSION['msg_success']='';
 }
 $success_block[] = '&lt;/ul&gt;';
 $success_block = implode('',$success_block);
}
</code></pre>

<p>The problem is that the clearing of the session var seems to have a retro-active effect so the message never gets displayed. It only works if I take out the line that re-sets it to an empty string. I'm thinking there's something about when session vars are evaluated that I don't understand?</p>
