Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Losing Session Variable on Page Post Back

Status
Not open for further replies.

romh

Programmer
Jan 3, 2003
297
US
Ok, here is my problem. I have a series of pages which depend on a session variable. This session variable is created from an integer identity field in the sql server 2000 database table. After the 1st page, each subsequent page reads this session variable at the beginning of each page.

The Second page of the sequence reads the session variable on the page load method. But any calls to this session variable after the page load method, return empty. Somehow, it is losing the session. I have done lots of research, but cannt find similar situations.

Another option is to use the SQL server session method. But this is slower, so i have not tried it yet.

If anybody has experienced this, please help.
 
Add trace="True" to your page tag on the aspx page and have a look at the session details to see if it really has been loast.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I added the trace ="true".

When the page first loads up, it displays the session state variable correctlt. But then, when i hit the submit button and page posts back, the session state variable is no longer there. So, what could be happening here.

Will I have to go with SQL server session storing?

 
the session state variable is no longer there
In that case it is either:

1) Being overwritten elsewhere
2) The session is timing out

I would rule out number one before looking into the second.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I decided to change from in process to sql server, but is still not working, This is very strange indeed. Would this be the right way to configure the web.config file?

<configuration>
<system.web>
<authentication mode="Forms" >
<forms loginUrl="url/frmlogin.aspx" name=".ASPNETAUTH" protection="None" path="/" timeout="30" >
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
<sessionState mode="SQLServer" "data source = 127.0.0.1;user id=id2;password=v4l1"
cookieless="false" timeout="20"/>
</sessionState>

</system.web>
</configuration>
 
Hi romh

You have set the session timeout as being less than the forms authentication. This means that the session invalidates in 20 minutes but the user is still logged in for another 10 minutes longer.

check to see if your problem is occuring only after the 20 minute timeout. if so then all you need to do is set the session and authentication timeouts to the same numbers. Then when the session invalidates it will also log the user out.

hope this helps (i realise this post is pretty old!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top