try using the web.config instead of session variable to restrict access.
web.config sample
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<system.web>
<sessionState mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;trusted_connection=true"
cookieless="false"
timeout="20" />
<customErrors mode="Off" />
<authentication mode="Forms">
<forms name=".ASPXAUTH"
loginUrl="index.aspx"
protection="All"
timeout="30"
path="/" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>
<location path="register.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="default.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="contact.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="getHint.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="admin">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
Key
Restricts access to pages not allowed below
annonymous access allowed
Restricted Directory