brijendra
brijendra

Reputation:

What is a session in ASP.NET, and how do I use it?

Can someone explain the concept of sessions in ASP.NET? How do I use them, and how do cookies fit in?

Upvotes: 2

Views: 801

Answers (4)

Andrew Siemer
Andrew Siemer

Reputation: 10278

A question like this makes me want to point you over to a post I did a while back (Should I Use a Framework While Learning Web Development) which will give you a heads up to other areas you might want to study up on. The topic of sessions is one of those bullet points.

I think that the idea of a session is well covered in the above posts so I won't further detail that!

Upvotes: 0

Andrew Hare
Andrew Hare

Reputation: 351456

Session is a per-user object for persisting state between HTTP requests. It is good for storing information that you will need on the server to properly serve requests back to the user (e.g. user name, email, etc.).

ASP.NET places a cookie on the client's machine that contains a GUID (in the case of cookieless sessions, this GUID is placed on the URL). This GUID is the user's session ID. This identifier is retrieved on each HTTP request from the client by the ASP.NET runtime. Subsequently this identifier is used to rehydrate the user's session data from the session's data-store (either in memory or in the database).

Upvotes: 1

JonnyD
JonnyD

Reputation: 591

Sounds like you're pretty new to ASP.NET. Rather than posting vague questions here, I would suggest you head over to http://www.ASP.net and check out their tutorials. They've got a lot of walkthroughs and articles that will give you a good overview of how ASP.NET state works.

Upvotes: 0

Sampson
Sampson

Reputation: 268324

Upvotes: 0

Related Questions