L4 - Session Management & Security Flashcards
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)
- Session is used to store information and identity. The server stores the session using Session_id.
- 2 events: Session_start(), Session_End()
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)
- Session timeout can be configured in the web.config file
- It indicates the time that the session can be idle before it is abandoned
- <sessionState></sessionState>
- By default, session timeout = 20minutes
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)
- State is maintained throughout till application shut down.
- Shared by all users accessing the application
- 3 events: Application_start(), Application_Error(), Application_End()
Cache (Server)
- Cache is stored on server side
- Cache is used to set expiration policies
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)
- Not stored in the client’s hard drive
permanently. - Once the user exits the browser, the cookies will be cleared
Control state
- A private ViewState for specific controls only
- to cahce data necessary for a control to function properly
- not affected when ViewState is turned off