session_start() doesn't work online
<p>I'm having a problem to set a session for a user. it's working in my localhost but online it doesn't work. </p>

<p>I have a username called 's' and I have created a page to see what is the problem</p>

<p>here is the code. test.php</p>

<pre><code>&lt;?php 
session_start();
require 'connect.php';

$username = @$_POST['username'];

?&gt;

&lt;div class="center_body"&gt;
    &lt;div class="search_field"&gt;
            &lt;form method="POST" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;
                &lt;table border="0" width="100%" cellspacing="0" cellpadding="0"&gt;
                    &lt;td align="left"&gt;username:&lt;/td&gt;
                    &lt;td align="right"&gt;&lt;input type="text" name="username" class="search" /&gt;&lt;/td&gt;
                &lt;/tr&gt;

                &lt;/table&gt;
                &lt;input type="submit" value="log in" class="search" /&gt;&lt;/p&gt;
            &lt;/form&gt;
            &lt;/tr&gt;

    &lt;/div&gt;
&lt;/div&gt;

&lt;?php
$result = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error);

    while($row = mysql_fetch_assoc($result))
    {
        $user = $row['username'];

    }

    if($username == $user)
    {
        echo '&lt;div class="search_field"&gt;&lt;b&gt;you have logged successfully&lt;/b&gt;&lt;/div&gt;&lt;/ br&gt;';
       $_SESSION['username'] = $username;

    }

    if(isset($_SESSION['username']))
    {
        echo $_SESSION['username'];
    }

?&gt;  
</code></pre>

<p>like above code, it works, and also I can print the username. but when I edit the test.php to be</p>

<pre><code>&lt;?php 
session_start();
require 'connect.php';
    if(isset($_SESSION['username']))
    {
        echo $_SESSION['username'];
    }

?&gt;  
</code></pre>

<p>now, this page should print username because I have successfully created the session. but it prints nothing so session seems not working</p>

<p>what do you thing is the problem?</p>

<p>EDIT: 
connect.php</p>

<pre><code>&lt;?php

$connect = @mysql_connect("localhost","root","") or die("error in connection");
$select  = @mysql_select_db("abc") or die ("no databse selected");

?&gt;
</code></pre>

<p>of course I changed data to be connected to my host databas</p>
