GalSuchetzky
GalSuchetzky

Reputation: 795

How does a server maintain the state of a session with a client?

I'm reading about session management in ASP.NET and I'm a bit confused.

This is what I understand:

Is this how it works or am I mixing things up? I read somewhere that the server can maintain the state with the cookie only but I don't understand if it's correct or possible (the last point in the bullet list).

Upvotes: 0

Views: 688

Answers (1)

JustAnotherDev
JustAnotherDev

Reputation: 672

You've got it right, that's how it normally works. In terms of cookies ASP.net does have a way of offering a session without a cookie, which it achieves by basically putting your cookie into the URL instead. That might be what you're thinking of.

Normally this isn't a great idea, it makes session hijacking as simple as copy pasting the victims URL into your own browser.

There are two ways that session state can store the unique ID that associates the client with a server session: by storing an HTTP cookie on the client or by encoding the session ID in the URL. Storing the session ID in the cookie is more secure but requires the client browser to support cookies.

From https://learn.microsoft.com/en-us/dotnet/api/system.web.configuration.sessionstatesection.cookieless?view=netframework-4.8

Upvotes: 1

Related Questions