Cookies (continue). Extracting Data From Cookies Data retrieved from a cookie is a simple text string. While there is no specific JavaScript function.

Slides:



Advertisements
Similar presentations
Cookies The HTTP protocol is stateless, that is, it does not maintain information on states after the session ends. But sometimes it is useful to remember.
Advertisements

ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming cookies.
LAADS Web Tutorial
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Cookies Purpose –Write information that lives after the browser exits –Keep track of form data submitted multiple times during a particular visit –Track.
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.
20/1/12.  Cookies are a useful way of storing information on the client’s computer  Initially feared, when they first appeared and were considered a.
XP Tutorial 9 New Perspectives on JavaScript, Comprehensive1 Working with Cookies Managing Data in a Web Site Using JavaScript Cookies.
Alexander Hartmann.  Free service offered by Google that generates detailed statistics about the visitors to a website. A premium version is also available.
Client-Side programming with JavaScript 3
Forms and Java script. Forms The graphical user interface -textbox, radio, button, textarea, checkbox… The processing script –CGI scripts, Perl script,
Review and Practice for Final exam. Final exam Date: December 20, 3:15 – 5:15pm Format: Two parts: First part: multiple-choice questions (15 questions.
Extracting the System Date  Built-in Date() object  Can be manipulated only by creating a new object instance  var variable = new object  var birthDay.
Online Shopping JavaScript project for CS 175 JavaScript for Web Development, Spring 2009 By Sita Akella.
Cookies and Security Saving the “state”
JavaScript, Fourth Edition
Sahar Mosleh PageCalifornia State University San Marcos 1 Storing Information: Cookies.
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.
CSE 154 LECTURE 12: COOKIES. Including files: include include("filename"); PHP include("header.html"); include("shared-code.php"); PHP inserts the entire.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Enhancing Web Pages  Use Notepad to open any html file  Adding an Animation  Google search ‘free animation’  After saving one, add it to the web page.
Week seven CIT 354 Internet II. 2 Objectives Database_Driven User Authentication Using Cookies Session Basics Summary Homework and Project 2.
Maintaining State MacDonald Ch. 9 MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
COOKIES. INTERNET COOKIES What are they Where are they found What should you do about them.
Regular Expression (continue) and Cookies. Quick Review What letter values would be included for the following variable, which will be used for validation.
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.
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
Introduction to Client-Side Web Development Introduction to Client-Side programming using JavaScript JavaScript; application examples 10 th February 2005.
The Web Wizard’s Guide To JavaScript Chapter 7 Cookies: Maintaining State.
JavaScript Part 9 George Mason University June 23, 2010.
V 1.0Slide 1 Staff - Training Information Click “Add” button to add a training record.
ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState.
Patron Self-Registration. Self-Registration As of September 2014, patrons may apply for a PINES library card through the PINES web site at:
Jan 2001C.Watters1 World Wide Web and E-Commerce Client Side Processing.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
CS 149 Advance Perl Final Project Implementing an E-commerce shopping cart using cookies Presented by Dzung Tran.
Persistence Maintaining state using cookies and queries.
Copyright ©2005  Department of Computer & Information Science Working with Cookies.
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.
(Some from Chapter 11.9 – “Web” 4 th edition and
PHP and Sessions. Session – a general definition The GENERAL definition of a session in the “COMPUTER WORLD” is: The interactions (requests and responses)
IS2802 Introduction to Multimedia Applications for Business Lecture 8: JavaScript and Cookies Rob Gleasure
MIT AITI 2004 JSP – Lecture 4 Sessions and Cookies.
Review and Practice for Final exam. Final exam Date: December 20, 3:15 – 5:15pm Format: Two parts: First part: multiple-choice questions (13 questions.
Project 5: Customizing User Content Essentials for Design JavaScript Level Two Michael Brooks.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Popup Boxes.
COOKIES Gloria Soria Network Security COSC 356. What is a Cookie? A cookie is a piece of text that a Web Server can store on a user's hard disk. Cookies.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Triple-click here to replace this text with your name and date!
JavaScript, Sixth Edition
COOKIES.
Insert Presentation Title Here Insert Presentation Summary Here
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.
Title of Your Event Event Date Event Time
Title of Your Event Event Date Event Time
SPECIALIST STATIONERY PTE LTD
New Client Guide.
CSc 337 Lecture 27: Cookies.
YOUR text YOUR text YOUR text YOUR text
Insert Presentation Title Here Insert Presentation Summary Here
Please insert Title Please insert sub-title 1
Client Side programming: Javascript, Cookies
Introduction to JavaScript
Business PowerPoint Template
Insert Presentation Title Here Insert Presentation Summary Here
CSc 337 Lecture 25: Cookies.
Presentation transcript:

Cookies (continue)

Extracting Data From Cookies Data retrieved from a cookie is a simple text string. While there is no specific JavaScript function for parsing the information from the text string, you can build a function using the indexOf() method. The text string returned from the cookie contains only the name=value pairs of information. var myCookie = document.cookie;

Create a Multiple Parameter Cookie Enter A User Name function getName(form) { var cookieExp = new Date(); var year = cookieExp.getTime() + (365 * 24 * 60 * 60 * 1000); cookieExp.setTime(year); var name = escape(form.field1.value); document.cookie = "userName=" + name + "; expires=" + cookieExp.toGMTString()+ "; path=/"; document.location='nextpage.htm'; } Please type in a user name:

nextpage.htm Continue Your Visit Thank you! document.write(" " + unescape(document.cookie) + " ")

Cookie with interactive web page Extracting Cookie Data Shopping.htm Shopping2.htm Shopping3.htm

Summary Cookies are widely used on the WEB They make tracking information about the user practical There are two types of cookies: Temporary – no expiration date Stored – future expiration date Deleting a cookie in JavaScript is accomplished by setting its expiration date to an earlier date than now Cookies can be updated Cookie information must be encoded using the escape() method and decoded using the unescape() method.

Practice Step 1: Making a Cookie // insert your Javascvript code here

Practice Step 2: create a form that looks like this picture (replace this Tshirt picture with any TShirt picture downloaded from google image search)

Practice Step 3: Use examples shown today in class to write a function create a cookie that contains “tshirt=white Tshirt”. Call this function when the user click on “Add to shopping cart” button Step 4: Use examples shown today in class to write a function view this cookie. Call this function when the user click on “View cart” button.