Session Tracking Lec 31. Revisiting Session Tracking HTTP is a stateless protocol  Every request is considered independent of every other request Many.

Slides:



Advertisements
Similar presentations
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK)
Advertisements

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.
Servlets and a little bit of Web Services Russell Beale.
Servlet Session I: Cookie API Road Map  Creating Cookies  Cookie Attributes  Reading Cookies  Example 1: Basic Counter  Example 2: Tracking Multiple.
Handling Cookies Vijayan Sugumaran Decision and Information Sciences Oakland University Parts of this presentation was provided by
XP Tutorial 9 New Perspectives on JavaScript, Comprehensive1 Working with Cookies Managing Data in a Web Site Using JavaScript Cookies.
Session Management A290/A590, Fall /25/2014.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
Chapter 10 Maintaining State Information Using Cookies.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
ASHIMA KALRA.  INTRODUCTION TO JSP INTRODUCTION TO JSP  IMPLICIT OBJECTS IMPLICIT OBJECTS  COOKIES COOKIES.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
CHAPTER 12 COOKIES AND SESSIONS. INTRO HTTP is a stateless technology Each page rendered by a browser is unrelated to other pages – even if they are from.
Comp2513 Java Servlets and Sessions Daniel L. Silver, Ph.D.
Servlets, Sessions, and Cookies Lecture 8 cs193i – Internet Technologies Summer 2004 Kelly Shaw, Stanford University.
IT533 Lectures Session Management in ASP.NET. Session Tracking 2 Personalization Personalization makes it possible for e-businesses to communicate effectively.
Chapter 8 Handling Cookies. Cookie Cookies are small bits of textual information that a Web server sends to a browser and that the browser later returns.
CSE 154 LECTURE 12: COOKIES. Including files: include include("filename"); PHP include("header.html"); include("shared-code.php"); PHP inserts the entire.
CS453: State in Web Applications (Part 1) State in General Sessions (esp. in PHP) Prof. Tom Horton.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Session tracking There are a number of problems that arise from the fact that HTTP is a "stateless" protocol. In particular, when you are doing on- line.
PHP1-1 PHP Lecture 2 Xingquan (Hill) Zhu
Session Tracking - 2 Lec 32. Last Lecture Review  Session Tracking – why?  Need to store state – typical solutions Cookies – already learned URL Rewriting.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
Web Application Development * These slides have been adapted and modified from CoreServlets course material (Marty Hall) and LUMS cs391 (Umair Javed).
Chapter 6 Server-side Programming: Java Servlets
Cookies Web Browser and Server use HTTP protocol to communicate and HTTP is a stateless protocol. But for a commercial website it is required to maintain.
Web Database Programming Week 7 Session Management & Authentication.
Saving Client State Session Tracking: Maintain state about series of requests from same client over time Using Cookies: Clients hold small amount of their.
ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState.
Saving State on the WWW. The Issue  Connections on the WWW are stateless  Every time a link is followed is like the first time to the server — it has.
CP476 Internet Computing CGI1 Cookie –Cookie is a mechanism for a web server recall info of accessing of a client browser –A cookie is an object sent by.
Slides © Marty Hall, book © Sun Microsystems Press 1 Handling Cookies Core Servlets & JSP book: More.
SE-2840 Dr. Mark L. Hornick1 Servlet Threads and Sessions.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
Slides © Marty Hall, book © Sun Microsystems Press 1 Session Tracking Core Servlets & JSP book: More.
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.
How to maintain state in a stateless web Shirley Cohen
©SoftMooreSlide 1 Session Tracking with Servlets.
Cookies Lack Integrity: Real-World Implications
CSC 2720 Building Web Applications Managing Users' States – Cookies, URL-Rewriting, Hidden Fields and Session Management APIs.
Servlets 4 Lec 30 Web Design and Development. Looking Back… Response Redirection  Sending a standard redirect  Sending a redirect to an error page Request.
MIT AITI 2004 JSP – Lecture 4 Sessions and Cookies.
Session Tracking Parts of this presentation was provided by SSE.
©SoftMooreSlide 1 Cookies. ©SoftMooreSlide 2 Cookies Basic idea –web application sends a simple name/value pair to the client –when the client connects.
ASP.NET Part II Dr. Awad Khalil Computer Science Department AUC.
8-Mar-16 More About Servlets Session Tracking. Persistent information A server site typically needs to maintain two kinds of persistent (remembered) information:
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Persistence Maintaining state: Queries. State is the Problem What is state? facebook status logins (which user are you?) conversations talking about what?
COOKIES AND SESSIONS.
1 Chapter 22 World Wide Web (HTTP) Chapter 22 World Wide Web (HTTP) Mi-Jung Choi Dept. of Computer Science and Engineering
Distributed Web Systems Cookies and Session Tracking Lecturer Department University.
CSE 154 Lecture 20: Cookies.
Sessions Many interactive Web sites spread user data entry out over several pages: Ex: add items to cart, enter shipping information, enter billing information.
Sessions.
Client / Session Identification Cookies
Cross-Site Request Forgery (CSRF) Attack Lab
CS320 Web and Internet Programming Cookies and Session Tracking
Session Hijacking Tarun Lall.
CS3220 Web and Internet Programming Cookies and Session Tracking
Cookies Cookies are small bits of textual information that a Web server sends to a browser and that the browser returns unchanged when later visiting the.
Session Tracking Techniques
Sessions Many interactive Web sites spread user data entry out over several pages: Ex: add items to cart, enter shipping information, enter billing information.
Web Programming Language
CS3220 Web and Internet Programming Cookies and Session Tracking
Pre-assessment Questions
[Based in part on SWE 432 and SWE 632 materials by Jeff Offutt, GMU]
Presentation transcript:

Session Tracking Lec 31

Revisiting Session Tracking HTTP is a stateless protocol  Every request is considered independent of every other request Many web applications need to maintain a conversational state with the client  A shopping cart is a classic example

Store State Somewhere Server Side?  Makes Server Really Complicated  State per client! Client Side?

“Post-Notes” Server puts little notes on the client side When client submits the next form, it also (unknowingly) submits these little notes Server reads the notes, remembers who the client is

Three Typical Solutions Cookies URL Rewriting Hidden Fields

Handling Cookies

Potential of Cookies Idea  Web server sends a simple name-value pair to client (web browser etc.)  Saved by the client  Later, Client returns same name and value when it connects to same site (or same domain, depending on cookie settings)

Potential of Cookies Typical Uses of Cookies  Identifying a user during an e-commerce session Servlets have a higher-level API for this task  Avoiding username and password  Customizing a site  Focused advertising

Sending Cookies to Browser Create a Cookie object Cookie c = new Cookie("name", "value"); Set the Maximum age etc  Cookie persists on disk c.setMaxAge(seconds); // Set other attributes. Place the Cookie into HTTP response  If you forget this step, no cookie will be sent to the browser response.addCookie(c);

Reading Cookies from Browser To read incoming cookies, get them from request object Cookie[] cookies = request.getCookies(); Once you have an array of cookies, you can iterate over it  Use getName and getValue to retrieve cookie name & value respectively for(int i=0; i<cookies.length; i++) { Cookie c = cookies[i]; if (c.getName().equals("someName")){ // doSomethingWith cookie break; }

Example 1: RepeatVisitor This servlet checks for a unique cookie, named “repeat”.  If the cookie is present, servlet says “Welcome Back”  Otherwise, servlet says “Welcome Aboard”.

Example Code Repeat Visitor

Using Cookies to Detect First-Time Visitors (Results)

HTTP Cookies String sID = makeUniqueString(); Hashtable sessionInfo = new Hashtable(); Hashtable globalTable = findTableStoringSessions(); globalTable.put(sID, sessionInfo); Cookie sessionCookie = new Cookie("JSESSIONID", sID); response.addCookie(sessionCookie); Credit: cs193i at Standford

HTTP Cookies String sID = makeUniqueString(); Hashtable sessionInfo = new Hashtable(); Hashtable globalTable = findTableStoringSessions(); globalTable.put(sID, sessionInfo); Cookie sessionCookie = new Cookie("JSESSIONID", sID); response.addCookie(sessionCookie); Credit: cs193i at Standford

HTTP Cookies String sID = makeUniqueString(); Hashtable sessionInfo = new Hashtable(); Hashtable globalTable = findTableStoringSessions(); globalTable.put(sID, sessionInfo); Cookie sessionCookie = new Cookie("JSESSIONID", sID); response.addCookie(sessionCookie); Credit: cs193i at Standford

HTTP Cookies String sID = makeUniqueString(); Hashtable sessionInfo = new Hashtable(); Hashtable globalTable = findTableStoringSessions(); globalTable.put(sID, sessionInfo); Cookie sessionCookie = new Cookie("JSESSIONID", sID); response.addCookie(sessionCookie); Credit: cs193i at Standford

HTTP Cookies String sID = makeUniqueString(); Hashtable sessionInfo = new Hashtable(); Hashtable globalTable = findTableStoringSessions(); globalTable.put(sID, sessionInfo); Cookie sessionCookie = new Cookie("JSESSIONID", sID); response.addCookie(sessionCookie); JSESSIONID → Credit: cs193i at Standford

HTTP Cookies String sID = makeUniqueString(); Hashtable sessionInfo = new Hashtable(); Hashtable globalTable = findTableStoringSessions(); globalTable.put(sID, sessionInfo); Cookie sessionCookie = new Cookie("JSESSIONID", sID); response.addCookie(sessionCookie); Set-Cookie: JSESSIONID= ; Credit: cs193i at Standford

HTTP Cookies Cookie: JSESSIONID= ; // On request String sID = getCookieValue("JSESSIONID"); Hashtable globalTable = findTableStoringSessions(); Hashtable sInfo = (Hashtable) globalTable.get(sID); // sInfo contains the data related to user Credit: cs193i at Standford

HTTP Cookies Cookie: JSESSIONID= ; // On request String sID = getCookieValue("JSESSIONID"); Hashtable globalTable = findTableStoringSessions(); Hashtable sInfo = (Hashtable) globalTable.get(sID); // sInfo contains the data related to user Credit: cs193i at Standford

HTTP Cookies Cookie: JSESSIONID= ; // On request String sID = getCookieValue("JSESSIONID"); Hashtable globalTable = findTableStoringSessions(); Hashtable sInfo = (Hashtable) globalTable.get(sID); // sInfo contains the data related to user Credit: cs193i at Standford

Example : Online Book Store using cookies netBeans project -CookieSessionEx