display message after login
<p>I have a PHP script that when user logs in it redirects back to Index and based on SESSION the index file loads guests or users template.</p>

<p>Now the problem is that I want to display something back to the user like Welcome back, John</p>

<p>And I am not exactly sure how to do it because I am using header to redirect user back to index as such</p>

<pre><code>header("Location: hello"); 
            die("Redirecting to: hello"); 

=======&gt; my current alternative
header("Location: hello?welcome-".sha1($_POST['username']).""); 
            die("Redirecting to: hello"); 

=======&gt; Feedback message is outputed as such
if( isset( $_GET['welcome-'.sha1(htmlentities($_SESSION['_cmd:ofau']['username'], ENT_QUOTES, 'UTF-8')).'']) ) { 
echo '&lt;div class="action-feed"&gt;
      Welcome back, '.htmlentities($_SESSION['_cmd:ofau']['username'], ENT_QUOTES, 'UTF-8').'&lt;/div&gt;
'; 
} 
</code></pre>

<p>What I am doing now is passing a value along with username hash back to header so when the user is redirected back to hello which is mod_rewriten index.php it reads the ?welcome- part with isset() statement and displays the message after which its cleared by jQuery via fadeIn(3000)</p>

<p>The problem as you may have guessed is the fact that I am passing the value back to user which I don't want to do, instead if user logs in the login script should push the user to index and jQuery should fire-up the message and hide it after 3000ms</p>

<p>Any suggestion how to do this? </p>

<p><strong>--- ANSWERED ---</strong></p>

<p>Figured out a working solution.</p>

<p>During login process I would create a welcome session and after the redirect set this settion to null</p>

<p>on login page</p>

<pre><code>$_SESSION['_cmd:welcome'] = '&lt;div class="action-feed"&gt;Welcome back,'.$_POST['username'].'&lt;/div&gt;';
</code></pre>

<p>on index (redirect destination)</p>

<pre><code>print $_SESSION['_cmd:welcome']; $_SESSION['_cmd:welcome'] = null;
</code></pre>

<p>Worked out fine so I will stick with this :)</p>
