I'm little-bit confused about session management in MVC4.
Lets say, I entered username and password and clicked on Login button. Then on server side, I got SessionId from HttpContext.Current.Session. And then I am validating that user credentials against database. If user is valid, then Adding SessionId, userName and uiserId in Session.
Lets say, next time request is came from same machine and same browser, I got same SessionId and then allowing that user to access other information.
Now I have following questions:
It is perfectly OK to use sessions in ASP.NET MVC, especially in the shopping cart scenario of yours.
When session state is enabled for an ASP.NET application, each request for a page in the application is examined for a SessionID value sent from the browser. If no SessionID value is supplied, ASP.NET starts a new session and the SessionID value for that session is sent to the browser with the response.
First I suggest to read this Wikipedia article about HTTP sessions. The answers on your question:
SessionId
in either a cookie
or the query string.SessionId
which was sent by the client in question 1. The server maintains for example a key value data object so it can load the right data for the given SessionId
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With