Session variable data being lost

G

Guest

Our website contains session variables that are used to validate if a user is
logged in etc. We have found that these variables are randomly lost while
navigating the website.

We set up some basic code (as shown below) which used a meta tag to refresh
an aspx page every second. It tests whether there is any content in a
session variable, if not then it writes a timestamp to a text file, recreates
the data in the variable and continues. As you can see this script contains
no databases calls etc.

<%response.write(session("Username") & "<br>" & Session.SessionID)
if len(session("Username"))=0 then
Dim FILENAME as String = Server.MapPath("Output.txt")
Dim objStreamWriter as StreamWriter
objStreamWriter = File.AppendText(FILENAME)
objStreamWriter.WriteLine(DateTime.Now.ToString())
objStreamWriter.Close()
session("Username") = "HelloWorld"
end if %>

The output looks like this:
18/04/2006 15:08:18
18/04/2006 15:11:37
18/04/2006 15:18:39
18/04/2006 15:21:40
18/04/2006 15:31:41
18/04/2006 15:34:43
18/04/2006 15:41:44
18/04/2006 15:50:46
18/04/2006 15:56:49
18/04/2006 15:58:47
18/04/2006 16:03:50
18/04/2006 16:06:49
18/04/2006 16:08:49
18/04/2006 16:11:50
18/04/2006 16:14:55
18/04/2006 16:16:55
18/04/2006 16:18:54
18/04/2006 16:23:00
18/04/2006 16:26:00
18/04/2006 16:31:01
18/04/2006 16:35:03
18/04/2006 16:37:05
18/04/2006 16:39:04
18/04/2006 16:41:06
18/04/2006 16:43:12
18/04/2006 16:45:10
18/04/2006 16:50:09

As you can see the session data is dropped usually under 10 minutes but
completely randomly. We have also found that the session id stays the same. I
assume the reason it does stay the same is because that specific data is held
on the client and passed to the server on every communication to the server.

Our webhosting does not support Stateserver or SQLServer state management,
so the only option is InProc. From searching several articles we have found
there are many reasons why this data can be lost. For example if any .config
files or bin files are changed or touched (eg by AV software) then the
application resets and therefore loses the session data. This has also been
tested by us and can confirm this happens.

As our website is hosted on a shared server, we assume that other sites are
or could be having similar issues as us.

Has anyone experienced this particular issue before?

Thanks in advance.

Regards

Sarah Marriott.
 
G

Guest

Hi Jeff,

Sorry for the late reply - you know how ISPs are at getting back to you :)

We asked the questions, and they stated that AV doesn't actually run on
their webservers.

Any other ideas?

Regards

Sarah
 
D

dfgallucci

I've been having strange problems for the past month, since going live
with a new site. (http://www.paintworldinc.com) At first I thought
these were user errors. As traffic has been steadily increasing, so
have these errors. They are EXACTLY as you describe. Sometimes, a user
will get as far as the checkout page, populate the form, then hit the
submit - that's when the system will throw an exception. I have code in
place to catch these errors, and write the exception.message text to
the database. They have been due to trying to insert a null into a
required database field - this is data that was held in a session
variable.

I was going to use persistent state - but my host provider does not yet
support it, although they might be turning this on as I write.

Aside from that, I may just implement my own custom session variable
store - using SQL Server as my storage.

If you solve this, please post back as to your own solution.

Regards,

-DG
 
G

Guest

Hi,

Our ISP finally got back to us saying that this problem is due to our site
being held on a Server Farm. There is nothing they will do to resolve this
issue. So we have had to handle it by storing a flag in the db which the code
checks if there is no session data available. If the flag has been set then
it re-establishes the session data. This is tedious and does result in more
calls to the db, but the site is more stable.

I'm guessing that you'll have to implement something similar or use the db
like you say.

This is rather annoying and I'm surprised more people are not complaining
about it. Maybe many people do not realise this is happening - scary!

Hope this helps.

Best regards,

Sarah
 
Joined
Oct 5, 2007
Messages
1
Reaction score
0
Forms losing data

We are also having stability problems in .Net 2.0 with forms losing data. The user logs in, enters data into the form which contains webparts, and despite the javascript assuring forms are not blank, the submit yields no data to the server. We have to reset the page to get it to work.

Thoughts?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top