declaring session variables php
<p>Is it not mandatory to use session_start() before using any session variables in PHP?
I tried the following piece of code without declaring session_start() at the beginning, it worked fine. </p>

<p>So, now I'm confused. Please help !!!!</p>

<p>Also, I did not use any $_POST or $_GET to pass $uname to home.php, but still how does it work? If we use include 'home.php' then does it treat login.php and home.php as same page?</p>

<pre><code>// code login.php//
&lt;?
require_once 'db_connect.php';

if (isset($_SESSION ['user_id']) &amp;&amp; !empty($_SESSION ['user_id']))
{

    $u_name = $_SESSION['user_name'];
    include 'home.php';
}
else
{
//some stmt
}
?&gt;

/*******home.php file ****/

&lt;?php
require_once 'dbconnect.php';
$_SESSION['username'] = $u_name;
//echo $_SESSION['username'];
//blah blah
?&gt;
</code></pre>
