Because of this nature of statelessness the end user who surfs your site can have undesirable results. For example take the example of the below interaction between server and client. See the last step where the user gets undesirable results. He was expecting a report but he is redirected to the login page.
So somehow we need to remind the server on which step or state we were , so that he can resume from that point. This is where we need to manage session.
Session management can be done by two ways:-
Now every time client visits the server the cookie value is sent reminding what is the state of the client so that server can work as per the state of the client. To retrieve cookie using ASP.NET server side programming language we need to use “Request” object and use the “Cookie” function to retrieve the value using the key.
So now if the client cookie says “LastPageVisited” was “Login” then the server should probably send him the “HomePage”.
- Server side session management (Session variables) :- Server side session management is done by using session variables. Session variables maintain data per user right from when the browser starts till the end. As soon as the browser is closed session variable is cleaned up. Below are the syntaxes to set session value and to get the value.
You can also watch this youtube video which is created by www.questpond.comThis video explains the difference between session and viewstate.