Presenter, Sai Krishna.  Introduction to session management  Ways of doing session management  Creating and Handling cookies  Problems with User sessions.

Slides:



Advertisements
Similar presentations
Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
Advertisements

HTTP HyperText Transfer Protocol. HTTP Uses TCP as its underlying transport protocol Uses port 80 Stateless protocol (i.e. HTTP Server maintains no information.
HTTP Hypertext Transfer Protocol. HTTP messages HTTP is the language that web clients and web servers use to talk to each other –HTTP is largely “under.
How the web works: HTTP and CGI explained
Web architecture Dr Jim Briggs Web architecture.
CSE 190: Internet Commerce Lecture 4: Web Servers.
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Know how HTTP accesses data on the WWW Objectives.
1 Web Search Interfaces. 2 Web Search Interface Web search engines of course need a web-based interface. Search page must accept a query string and submit.
The World Wide Web and the Internet Dr Jim Briggs 1WUCM1.
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
How Clients and Servers Work Together. Objectives Learn about the interaction of clients and servers Explore the features and functions of Web servers.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Hypertext Transport Protocol CS Dick Steflik.
CSC 2720 Building Web Applications Servlet – Getting and Setting HTTP Headers.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Web Servers Web server software is a product that works with the operating system The server computer can run more than one software product such as .
Web technologies and programming cse hypermedia and multimedia technology Fanis Tsandilas April 3, 2007.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Basic Network Services IMT 546 – Lab 4 December 4, 2004 Agueda Sánchez Shannon Layden Peyman Tajbakhsh.
FTP (File Transfer Protocol) & Telnet
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
IT533 Lectures Session Management in ASP.NET. Session Tracking 2 Personalization Personalization makes it possible for e-businesses to communicate effectively.
CSC 2720 Building Web Applications Getting and Setting HTTP Headers (With PHP Examples)
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
Application Layer 2 Figures from Kurose and Ross
© Janice Regan, CMPT 128, Jan 2007 CMPT 371 Data Communications and Networking HTTP 0.
Session 10: Managing State. Overview State Management Types of State Management Server-Side State Management Client-Side State Management The Global.asax.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Managing State.
State Management. What is State management Why State management ViewState QueryString Cookies.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Chapter 5 HTTP Request Headers. Content 1.Request headers 2.Reading Request Headers 3.Making a Table of All Request Headers 4.Sending Compressed Web Pages.
1 Introductory material. This module illustrates the interactions of the protocols of the TCP/IP protocol suite with the help of an example. The example.
World Wide Web (WWW) A Distributed Document- Based System Group E Ricky Tong (D-A0-1611) Eddy Leong (D-A0-1623) Dick Lei (D-A0-1658)
ASP.NET State Management. Slide 2 Lecture Overview Client state management options Cookies Server state management options Application state Session state.
Session and Cookie Management in.Net Sandeep Kiran Shiva UIN:
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
1 CS 4396 Computer Networks Lab TCP/IP Networking An Example.
Module 7: Creating a Microsoft ASP.NET Web Application.
A Little Bit About Cookies Fort Collins, CO Copyright © XTR Systems, LLC A Little Bit About Cookies Instructor: Joseph DiVerdi, Ph.D., M.B.A.
MEMBERSHIP AND IDENTITY Active server pages (ASP.NET) 1 Chapter-4.
GUDURU PRAVEEN REDDY.NET IMPERSONATION. Contents Introduction Impersonation Enabled Impersonation Disabled Impersonation Class Libraries Impersonation.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
WEB SERVER Mark Kimmet Shana Blair. The Project Web Server Application  Receives request for web pages or images from a client browser via the internet.
CITA 310 Section 2 HTTP (Selected Topics from Textbook Chapter 6)
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
HTTP How the Internet servers and clients communicate.
HTTP Here, we examine the hypertext transfer protocol (http) – originally introduced around 1990 but not standardized until 1997 (version 1.0) – protocol.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
1 10/19/05CS360 Windows Programming ASP.NET. 2 10/19/05CS360 Windows Programming ASP.NET  ASP.NET works on top of the HTTP protocol  Takes advantage.
Overview of Servlets and JSP
Configuring and Deploying Web Applications Lesson 7.
PHP Security Ryan Dunn Jason Pack. Outline PHP Overview PHP Overview Common Security Issues Common Security Issues Advanced Security Issues Advanced Security.
SESSION AND COOKIE MANAGEMENT IN.NET. Topics Covered Introduction to session management Ways of doing session management Creating and Handling cookies.
LURP Details. LURP Lab Details  1.Given a GET … call a proxy CGI script in the same way you would for a normal CGI request  2.This UDP perl.
COMP2322 Lab 2 HTTP Steven Lee Jan. 29, HTTP Hypertext Transfer Protocol Web’s application layer protocol Client/server model – Client (browser):
JAVA, JEE Training Introduction to Web Harinath Mallepally
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
DEV336. demo HTTP Packet Trace GET / HTTP/1.1 Accept: text/html, application/xhtml+xml, */* Accept-Language: en-US User-Agent: Mozilla/5.0 (compatible;
ASP.NET Essentials State management, authentication, and Web Services Daniele Pagano Arizona State University.
© Janice Regan, CMPT 128, Jan 2007 CMPT 371 Data Communications and Networking HTTP 0.
Fiddler and Your Website Robert Boedigheimer. About Me Web developer since 1995 Columnist for aspalliance.com Pluralsight Author 3 rd Degree Black Belt,
COMP2322 Lab 2 HTTP Steven Lee Feb. 8, 2017.
Web Caching? Web Caching:.
IS333D: MULTI-TIER APPLICATION DEVELOPMENT
Session management.
What is Cookie? Cookie is small information stored in text file on user’s hard drive by web server. This information is later used by web browser to retrieve.
CSCI-351 Data communication and Networks
Presentation transcript:

Presenter, Sai Krishna

 Introduction to session management  Ways of doing session management  Creating and Handling cookies  Problems with User sessions  Improved models and solutions  Session state element  References

 A session is defined as the period of time that a unique user interacts with a Web application.  Programmatically, session state is nothing more than memory in the shape of a dictionary or hash table, e.g. key-value pairs, which can be set and read for the duration of a user's session

 Session("Stocks") = "MSFT; VRSN; GE"  On subsequent pages these values are read and the Web application has access to these values without the user re-entering them: ' Get Stocks, split string, etc. Dim StockString StockString = Session("Stocks")

 Session management in ASP.NET can be done in two ways: Using Cookies Encoding of URLs with Session ID

Cookie-based Session Handling  To enable cookie-based session handling, make sure that web.config file of the web-application contains the following entry: Let’s say the browser makes a request to a server. This is the first request from the browser to the server. For e.g. for a request: The HTTP request header sent by the browser would be as shown below: 1. GET /WebApplication1/WebForm1.aspx HTTP/ Accept: image/gif, image/x- xbitmap, image/jpeg, image/ pjpeg, application/vnd.ms-excel, application/vnd.ms- powerpoint, application/ msword, application/x-shockwave-flash, */* 3. Accept-Language: en-us 4. Accept-Encoding: gzip, deflate 5. User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Avant Browser [avantbrowser.com];.NET CLR ) 6. Host: localhost 7. Connection: Keep-Alive

 The response send back by the server would consist of a HTTP response header and response body. The response header would look something like this: 1. HTTP/ OK 2. Server: Microsoft-IIS/ Date: Wed, 07 Jan :31:07 GMT 4. X-Powered-By: ASP.NET 5. X- AspNet-Version: Set- Cookie: ASP.NET_SessionId=ll345q550ozqll45qithgi45; path=/ 7. Cache-Control: private 8. Content-Type: text/html; charset=utf-8 Content- Length: 540

 If the browser clicks on a button of the first page to make a request to WebForm2.aspx, the request header sent would be: GET /WebApplication1/WebForm2.aspx HTTP/1.1 Accept: */* Accept-Language: en-us Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Avant Browser [avantbrowser.com];.NET CLR ) Host: localhost Connection: Keep-Alive Cookie: ASP.NET_SessionId= ll345q550ozqll45qithgi45

 For cookie-less Session handling we need to set the ‘cookieless’ attribute to ‘true’ in web.config. The request header is as shown below. (Similar to earlier request header in cookie-based session handling) 1. GET /WebApplication1/WebForm1.aspx HTTP/ Accept: image/gif, image/x- xbitmap, image/jpeg, image/ pjpeg, application/vnd.ms-excel, application/vnd.ms- powerpoint, application/ msword, application/x-shockwave-flash, */* 3. Accept-Language: en-us 4. Accept-Encoding: gzip, deflate 5. User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Avant Browser [avantbrowser.com];.NET CLR ) 6. Host: localhost 7. Connection: Keep-Alive

 The response returned by the browser is as follows HTTP/ Found Server: Microsoft-IIS/5.0 Date: Wed, 07 Jan :25:25 GMT X-Powered-By: ASP.NET X- AspNet-Version: Location:/WebApplication1/(bcgmybvma1y45czof4me3sq4)/WebForm1.asp x Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Length: 174 Object moved Object moved to h ere.

 The Request header it sends would be as shown below: GET /WebApplication1/(bcgmybvma1y45czof4me3sq4)/WebForm1.aspx HTTP/1.1 Accept: image/gif, image/x- xbitmap, image/jpeg, image/ pjpeg, application/vnd.ms-excel, application/vnd.ms- powerpoint, application/ msword, application/x-shockwave- flash, */* Accept-Language: en-us Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Avant Browser [avantbrowser.com];.NET CLR ) Host: localhost Connection: Keep-Alive

 A Cookie is a small text file that the browser creates and stores on the hard drive of your machine. Cookie is just one or more pieces of information stored as text strings.  The most common use of a cookie is to store information about the user and preferences the user makes.

 The System.Web namespace offers a class called HttpCookie to create cookies. Private Sub Select_Click(By Val sender As System.Object, By Val e As_ System.EventArgs) Handles Select.Click Dim newCookie As HttpCookie = New HttpCookie("Books") newCookie.Values.Add("Name", TextBox1.Text) newCookie.Values.Add("FavBook", RadioButtonList1.SelectedItem.Text) newCookie.Expires = #12/31/2008# Response.Cookies.Add(newCookie) Label3.Text = "Cookie Created" Select.Visible = False TextBox1.Visible = False Label1.Visible = False Label2.Visible = False RadioButtonList1.Visible = False End Sub

 Private Sub Retrieve_Click(By Val sender As System.Object, By Val e As_ System.EventArgs) Handles Retrieve.Click Label3.visible=False Label4.Text = "Hello" &" "& Request.Cookies("Books")("Name") & "."&_ "We have a new book for you:" If Request.Cookies("Books")("FavBook") = "VB" Then Label5.text="XYZ VB Book" ElseIf Request.Cookies("Books")("FavBook") = "C#" Then Label5.text="ABC C# Book" Else Label5.text="Startvbdotnet.com's ASP Book" End If End Sub

 Enter your Name Select your interest  VB  C#  ASP Cookie details  Hello Username. We have a new book for you: XYZ VB Book

 HttpCookie aCookie = new HttpCookie("Mycookie"); aCookie.Values["userName"] = “user name"; aCookie.Values["lastVisit"] = DateTime.Now.ToString(); aCookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(aCookie);  The cookie that will be created with the code will be in the form of and it can be found in C:\Documents and Settings\Administrator\Cookies.

These limitations include:  Process dependent.  Server farm limitations.  Cookie dependent.

 The stateless nature of HTTP makes the inclusion of a mechanism to save application state between user requests a must—the server must be able to identify the same user across multiple requests.  First, the 120-bit session ID used to identify the session is always stored as a cookie on the browser. So, if the security policy of a user's employer disallows cookies, the Session object cannot be populated.  Second, the data associated with the session and accessed through the session ID is stored on the Web server that processed the initial request and started the session. As a result, the session data can’t be shared in a web farm scenario where multiple web servers are processing requests from multiple clients.

ASP.NET session state solves all of the above problems associated with classic ASP session state:  Process independent  Support for server farm configurations.  Cookie independent.

 The ASP.NET session implementation addresses both of these weaknesses by allowing for "cookieless" sessions and off-server storage of session data. The ASP.NET session state module is configured declaratively in the Web.config file like so: In this case, the mode attribute is set to InProc (the default) to indicate that the session state is stored in memory by ASP.NET and that cookies will not be used to pass the session ID. Instead, the session ID is inserted into the query string for a page’s URL.

 For example, using InProc mode, after a session is established, a call to a hypothetical ASP.NET page would look something like the following: education.aspx ASP.NET offers three session management solutions. They are:  InProcess,  StateServer (outProcess),  SQLServer (database based)

 InProc: This is same as the conventional ASP session management. Session is stored in memory on the web server.  StateServer session management By setting the mode attribute to StateServer, is storing session data in a separate in-memory cache controlled by a Windows service running on a separate machine. The state service, called the ASP.NET State Service (aspnet_state.exe), is configured by the stateConnectionString attribute in the Web.config file. It specifies the service’s server and the port it monitors: using the state service has the advantages of process isolation and sharability across a web farm.

 Session management with SQL Server In this case, ASP.NET attempts to store session data on the SQL Server specified by a sqlConnectionString attribute that would contain the data source and security credentials necessary to log on to the server. To configure the SQL Server with the appropriate database objects, an administrator would also need to create the ASPState database by running the InstallState.sql script found in the WinDir\ Microsoft.Net\Framework\Version folder (where WinDir is the name of your server’s Windows folder and Version is the installation folder for the appropriate version of the.NET Framework you’re using). osql –S localhost –U sa –P –i Installsqlstate.sql ( cmd prompt) Once the SQL Server is configured, the application code should run identically to the InProc mode.  By storing session state in the database, you’re effectively trading performance for scalability and reliability.

 To use StateServer mode  Make sure ASP.NET state service is running on the remote server that will store session state information. This service is installed with ASP.NET and is located by default at :\systemroot\Microsoft.NET\Framework\version\aspnet_s tate.exe.  In the application's Web.config file, set mode=StateServer and set the stateConnectionString attribute. For example, stateConnectionString="tcpip=dataserver:42424".  To use SQLServer mode  Run InstallSqlState.sql (installed by default in :\systemroot\Microsoft.NET\Framework\version) on the computer running SQL Server that will store the session state. This creates a database called ASPState with new stored procedures and ASPStateTempApplications and ASPStateTempSessions tables in the TempDB database.  In the application's Web.config file, set mode=SQLServer and set the sqlConnectionString attribute. For example, sqlConnectionString="data source=localhost; Integrated Security=SSPI; Initial Catalog= northwind".

 InProc - stored in memory on web server This is the default setting.  Pros: least overhead, fastest performance  Cons: breaks web clusters, restarting IIS loses sessions  StateServer - managed by a remote service ( aspnet_state ) HTTP protocol over TCP port.  Pros: reasonably fast, works with clusters  Cons: clear text, no authentication, overflows...  SQLServer - stored in SQL Server DB tables Uses normal ODBC connection.  Pros: reliable, scalable  Cons: relatively slow, much overhead

 us/library/ms aspx  mentAspNet.asp  p  us/library/h6bb9cz9(vs.71).aspx  x  us/library/ms aspx