Session variables lost after redirect (using header)
<p>I have been learning PHP and MySQL for some time now and I encountered a problem.
I have created a user database (MySQL), login form and page where you are supposted to be redirected after succesful login.</p>

<p>Login page</p>

<pre><code>&lt;?php 

require_once 'login.php'; //connecting to db
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());

mysql_select_db($db_database)
or die("Unable to select database: " . mysql_error());

session_start(); //
if (isset($_POST['username']) &amp;&amp;
isset($_POST['password']))

{
$username = $_POST["username"];
$password = $_POST["password"];

$salt1 = "qm&amp;h*";
$salt2 = "pg!@";

$query = "SELECT * FROM login WHERE username='$username'";
$result = mysql_query($query);
if (mysql_num_rows($result) == 0) die("Wrong username or password.");

elseif (mysql_num_rows($result))
{
    $row = mysql_fetch_row($result);
    $crypt_login_pass = md5("$salt1$password$salt2");
    if ($crypt_login_pass == $row[2])
    {
        $_SESSION['username'] = $username;
        $_SESSION['password'] = $crypt_pass;

        header("Location: index_account.php");
        exit;
    }
    else {
        die("Wrong username or password.");
    }   
}
}
?&gt;
</code></pre>

<p>The code ran flawlessly until I added the <code>header("Location: index_account.php")</code>. I used to have there just <code>die("You are now logged in.")</code>.
And here is the page you are supposted to be redirected to:</p>

<pre><code>&lt;?php
session_start();
if (isset($_SESSION['username']) &amp;&amp;
isset($_SESSION['password']))
{
$username = $_SESSION['username'];
$password = $_SESSION['password'];

echo "Your username is '$username'
and your crypted password is '$password'.";
}
else echo "Please &lt;a href=index.php&gt;click here&lt;/a&gt; to log in.";
?&gt;  
</code></pre>

<p>All this code is running on localhost.
The problem is that the $_SESSION['username'] and $_SESSION['password'] won't transfer to the second page (index_account.php). I have read many post and the most similiar I've found is this: <a href="http://stackoverflow.com/questions/11397418/session-variables-lost-after-header-redirect">Session variables lost after header redirect</a> but without answear. 
Note that this is my first programing language (excluding HTML and CSS) and I am still very new to this. </p>

<p>P.S. Sorry for my Enlish. It's not my native language.</p>

<p>Thanks in advance!</p>
