Persistence Maintaining state using cookies and queries.

Slides:



Advertisements
Similar presentations
CookiesPHPMay-2007 : [‹#›] Maintaining State in PHP Part I - Cookies.
Advertisements

UFCE8V-20-3 Information Systems Development 3 (SHAPE HK)
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming cookies.
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Lesson 8 Cookies. What is a cookie A little “tarball” of information stored on the client machine’s hard drive. –Usually in the cookies.txt file –information.
JavaScript Forms Form Validation Cookies CGI Programs.
Web-based Application Development Lecture 20 April 4, 2006 Anita Raja.
HTTP Cookie CSC 667/867. PERSISTENT CLIENT STATE HTTP COOKIES Cookies are a general mechanism which server side connections (such as CGI scripts) can.
XP Tutorial 9 New Perspectives on JavaScript, Comprehensive1 Working with Cookies Managing Data in a Web Site Using JavaScript Cookies.
Chapter 10 Managing State Information PHP Programming with MySQL.
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.
Objectives Learn about state information
Chapter 9 Using Perl for CGI Programming. Computation is required to support sophisticated web applications Computation can be done by the server or the.
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.
Chapter 16 The World Wide Web. 2 The Web An infrastructure of information combined and the network software used to access it Web page A document that.
IT533 Lectures Session Management in ASP.NET. Session Tracking 2 Personalization Personalization makes it possible for e-businesses to communicate effectively.
Cookies and Security Saving the “state”
JavaScript, Fourth Edition
Working with Cookies Managing Data in a Web Site Using JavaScript Cookies* *Check and comply with the current legislation regarding handling cookies.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Week 9 PHP Cookies and Session Introduction to JavaScript.
CSE 154 LECTURE 12: COOKIES. Including files: include include("filename"); PHP include("header.html"); include("shared-code.php"); PHP inserts the entire.
USING PERL FOR CGI PROGRAMMING
Chapter 8 Cookies And Security JavaScript, Third Edition.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Regular Expression (continue) and Cookies. Quick Review What letter values would be included for the following variable, which will be used for validation.
1 Maryland ColdFusion User Group Session Management December 2001 Michael Schuler
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.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
PHP Programming with MySQL Slide 10-1 CHAPTER 10 Managing State Information.
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
JavaScript Part 9 George Mason University June 23, 2010.
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.
PHP Cookies. Cookies are small files that are stored in the visitor's browser. Cookies can be used to identify return visitors, keep a user logged into.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
Copyright ©2005  Department of Computer & Information Science Working with Cookies.
Cookies (continue). Extracting Data From Cookies Data retrieved from a cookie is a simple text string. While there is no specific JavaScript function.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
Cookies. Cookie A cookie is a method for a Web server to maintain state information about users as users navigate different pages on the site, and as.
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.
©SoftMooreSlide 1 Session Tracking with Servlets.
SESSIONS 27/2/12 Lecture 8. ? Operator Similar to the if statement but returns a value derived from one of two expressions by a colon. Syntax: (expression)
PHP and Sessions. Session – a general definition The GENERAL definition of a session in the “COMPUTER WORLD” is: The interactions (requests and responses)
©SoftMooreSlide 1 Cookies. ©SoftMooreSlide 2 Cookies Basic idea –web application sends a simple name/value pair to the client –when the client connects.
Project 5: Customizing User Content Essentials for Design JavaScript Level Two Michael Brooks.
Cookies and Sessions in PHP. Arguments for the setcookie() Function There are several arguments you can use i.e. setcookie(‘name’, ‘value’, expiration,
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.
Sessions and cookies (part 2) MIS 3501, Fall 2015 Brad N Greenwood, PhD Department of MIS Fox School of Business Temple University 11/19/2015.
Persistence Maintaining state: Queries. State is the Problem What is state? facebook status logins (which user are you?) conversations talking about what?
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
1 Chapter 22 World Wide Web (HTTP) Chapter 22 World Wide Web (HTTP) Mi-Jung Choi Dept. of Computer Science and Engineering
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
HTTP Transactions 1. 2 Client-Server Model 3 HTTP HyperText Transport Protocol Native protocol for WWW Sits on top of internet’s TCP/IP protocol HTTP.
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
The need for persistence Consider these examples  Counting the number of “hits” on a website  i.e. how many times does a client load your web page source.
Cookies Tutorial Cavisson Systems Inc..
CSE 154 Lecture 20: Cookies.
JavaScript, Sixth Edition
19.10 Using Cookies A cookie is a piece of information that’s stored by a server in a text file on a client’s computer to maintain information about.
Client / Session Identification Cookies
Cookies and Sessions in PHP
Cookies and JavaScript
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.
Client / Session Identification Cookies
Session Tracking Techniques
Advanced Concepts and AJAX
Presentation transcript:

Persistence Maintaining state using cookies and queries

State is the Problem What is state? facebook status mailbox flag conversations talking about what? talking to whom?

HTTP Protocol Stateless by design! Your machine & the server do not know What website you were on What you just did on the website Who you are page to page Each page is INDEPENDENT / SEPARATE

Why do you care? Maintain items in a shopping cart Website User Accounts Web Apps using more than ONE page Allow bookmarks of query results Polling, Statistics, Advertising

Top 2 Techniques URL Query Strings Cookies

Query string URL (Uniform Resource Locator) delineator character: ? location ( query=”what is a cookie?” 0a%20cookie?

write the right side of ? form tags’ names and values are converted into a URL query string onsubmit tag attributes containing URLs the DOM window.location object

demo Google

DOM location location.search = string of the ? side String object has methods! substring(), substr() split() is extremely useful!.length = # of how long string is location.search.substring(start,length);

Cookies AKA: tokens or tickets Browser stores a STRING of data for you Browser sends server STRING for every http connection it makes Server can send browser STRING to store as well

How does it work? Browser keeps STRING stored by website Sends STRING only to that website unless Temporary - dies when browser quits Expiration date passed Max string size of 4KB Max 20 cookies per server

document.cookie string object but HACKED strict complex formatting rules String object methods are needed string must be valid URL! encodeURI() & decodeURI() add / remove %## codes; %20 = space

Cookie attributes NOT an object (but should have been) so each “attribute” is formatted into the cookie string and the browser parses the info right back out again name=value; attribute=av; attribute2=av2

Expires attribute Date → specified in UTC format Weekday Mon DD HH:MM:SS Time Zone YYYY Set manually or Date object/methods Delete cookie: set date in the past

Path attribute Determines availability of cookie to other Web pages on a server Syntax: document.cookie = (“x=123“ + “;path=/MyFiles”); Use slash (/) to indicate root directory

Domain attribute Used for sharing cookies across multiple servers in the same domain Syntax: document.cookie = (“x=123“ + “; domain=.xyz.com”);

Secure attribute Indicates that a cookie can only be transmitted across a secure Internet connection using HTTPS or another security protocol Syntax document.cookie = (“x=123“ + “; secure=true”);

Reading Cookies Cookies are a string that must be parsed Decode cookie using decodeURI() method Use split() method to place each name=value pair into an array Use String object methods to extract required portions of each array element

Simple Example document.cookie= encodeURI("name=mycookie string; secure"); x = document.cookie x is name=mycookie%20string; oldname=oldcookie you may see cookies returned! use split()

DEMO

Security Queries are not secure Cookies are not secure Easily accessible and editable! Cookies can be set secure - browser will only send over HTTPS but are not that safe