HTTP
HTTP is a stateless protocol.
- It follows a request/response pattern i.e, user requests a resource and the web server responds with the requested resource.
- Information is not retained (pass on) from one request to another.
Client side session management
View state, hidden field, cookies, control state, query string
Server side session management
Session, application object, caching
Session (Server)
How to create a session variable (Server)
Session.add(“ssuser”, txtboxloginid.Text);
Session[“ssuser”] = txtboxloginid.Text;
How to retrieve value from session (Server)
string LoginUser = (String)Session[“ssuserName”]
How to delete session object(s) (Server)
Session.Remove(“cartvalue”)
Session.Abandon(); // Remove all objects
Session Timeout (Server)
How is data stored in “Session” (Server)
– InProc Mode
* It is a default session mode and a value store in web server
memory (IIS).
* Session value stored when server starts and it ends when
the server is restarted.
* limited to ONLY one server
– State Server Mode
* In this mode session data is stored in separate server.
– SQL Server Mode
* In this session is stored in the database. It is a secure mode
Application (Server)
Cache (Server)
Cookies (Client)
– a small amount of data which is either stored at client side in text file or in memory of the client browser session.
– Every time a user visits a website, cookies are retrieved from the user
machine and help identify the user.
Persistent Cookie (Client)
Cookies having an expiration data is called persistent cookie. This type of cookie reaches their end as their expiration dates comes to an end. IN this cookie we set an expiration date
Non persistent cookie (Client)
Control state
Hidden Field
Viewstate
– stores any type of data (small data)
– enables and disables on page level control.
– supports Encryption and Decryption and data/value is
stored in hashed format.
Query String
Broken Authentication and Session Managment Prevention
Session Fixation
How to prevent Session FIxation Attack
ASP.NET_SessionId Issue
When the user clicks on the logout button, the ‘btnLogout_Click’ event will be triggered. This event removes all sessions. Also, we are explicitly removing the values of thecookies ‘ASP.NET_SessionId,’ and ‘AuthToken’ so that an attacker cannot fixate the session.