Link to home
Create AccountLog in
Avatar of mmq2006
mmq2006

asked on

Web Sessions in C# (VS2005)

I developed a web application which has many aspx forms & master page as well. This application is being used by many users at the same time from the web. I discovered lately that data inserted into DB is messed up since I am not using sessions. I thought the web browser will take care of this but it does not.

I need an assistance in showing:
* how to create sessions?
* where to create sessions?
* how to store/retrieve data form the sessions & from different forms?
* how to end sessions?
* will this ensure the user data is accurate?
* will the session store data from all web forms?
Avatar of jandromeda
jandromeda
Flag of Sri Lanka image

You cannot create sessions. A session is created once an initial request has been made to the site and a session will be ended once the browser is closed or at the session timeout period completes. Here is how you can store/retrieve data to and from the session.

Session["Key1"] = Data;

data = Session["Key1"] as Data;

As I said earlier a Session spans throughout till a user closes his/her browser window or at the timeout period completes. We cannot exactly say that the sessions will ensure the accuracy of user data.
ASKER CERTIFIED SOLUTION
Avatar of jandromeda
jandromeda
Flag of Sri Lanka image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of mmq2006
mmq2006

ASKER

The reason of asking this question is that I have a web application (reservation system) which takes input from users from 3 steps (pages). However; i found out that some users data were exchanged in the DB bcz they were utilzing the system at the same time. so i thought session will resolve this bug.
I have gone over the provided links to get more details. Hope i have clear question points.