ASP.net page_load doesn't detect session
<p>I have a problem with using <code>session</code> variable in the <code>page_load</code>. I have a page (<code>members.aspx</code>) which is a members area. </p>

<p>If the user isn't <code>logged</code> in, it will display a form asking them to login. The form submits their details, checks if ok then sets <code>session</code> variables if <code>OK</code>. It then reloads the page.</p>

<p>So if the user has authenticated correctly, it sets <code>Session["memberLoggedIn"] = true</code>. 
My <code>page_load</code> function then looks like this</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    if (Convert.ToBoolean(Session["memberLoggedIn"]) == true) {
        Response.Write("OK");
    }
}
</code></pre>

<p>There is more code, but essentially, the "OK" should be written. However, it doesn't appear. Even though the <code>session</code> IS set. If I go to the page directly it will then show. It's just for the reloading of the members page from the initial login which stops it. </p>

<p>any ideas?!</p>

<p>======================
the code to set the session is</p>

<pre><code>if (logindetails.Count &gt; 0) {
    System.Data.DataRow details = logindetails[0];
    Session["memberLoggedIn"] = true;
}
</code></pre>

<p>I then just check if <code>(Convert.ToBoolean(Session["memberLoggedIn"]) == true)</code> on all my pages. To be honest it doesn't seem that reliable and I Think sometimes I need to understand the order in which pages are loaded as when I destroy the session on the log out page, some parts still show the logged in features! (but that's another story....)</p>
