Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sessionstate not being saved between pages

i am having problems with an asp.net c# site whereby i am setting a session state object to true and then redirecting to another page that needs to check the value of the session state object and it is null.

Sometimes it is set correctly and other times is is simply null.

When i debug on my local machine it works perfectly every time. Only when i upload to my web server does this temperamental behaviour happen.

As it is based around the security of the site it is obviously important that the session data be valid and accurate every time.

Is session state data unreliable?

AFAIK its set to inproc, cookieless, 30 min timeout, vanilla installation of IIS.

Does anyone have any suggestions? Perhaps i need to thread.sleep inbetween the storing of the session data and the reading?

NB: the time between the write and the read is about 70ms.. ample time for the data to be written to RAM.....

like image 783
Grant Avatar asked May 03 '10 13:05

Grant


1 Answers

No. It sounds like you are misusing session state. You can not rely on the user's session to be there. Your ASP.NET worker process could recycle, restarting the application and killing all sessions, or a file could change in your website, causing your application to restart and flushing all sessions, cookies could get flushed on the client, timeouts could happen, etc.

So you have to provide for all of these scenarios with Session State. Try to avoid using session state for things like this. If you're setting access inside your session state and you don't know exactly how it works, you could be opening your site up for a lot of security risks.

like image 194
Dave Markle Avatar answered Oct 04 '22 15:10

Dave Markle