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.

Slides:



Advertisements
Similar presentations
CookiesPHPMay-2007 : [‹#›] Maintaining State in PHP Part I - Cookies.
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.
JavaScript and AJAX Jonathan Foss University of Warwick
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.
Cookies Purpose –Write information that lives after the browser exits –Keep track of form data submitted multiple times during a particular visit –Track.
6/10/2015Cookies1 What are Cookies? 6/10/2015Cookies2 How did they do that?
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.
Computer Science 103 Chapter 4 Advanced JavaScript.
XP Tutorial 9 New Perspectives on JavaScript, Comprehensive1 Working with Cookies Managing Data in a Web Site Using JavaScript Cookies.
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.
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.
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.
Web Programming Language Week 7 Dr. Ken Cosh Security, Sessions & Cookies.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Week seven CIT 354 Internet II. 2 Objectives Database_Driven User Authentication Using Cookies Session Basics Summary Homework and Project 2.
COOKIES. INTERNET COOKIES What are they Where are they found What should you do about them.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
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.
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.
7 Chapter Seven Client-side Scripts. 7 Chapter Objectives Create HTML forms Learn about client-side scripting languages Create a client-side script using.
COOKIES and SESSIONS. COOKIES A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each.
Chapter 9 Building the Shopping cart Objective Creating Shopping cart using session Variable. Creating a shopping cart using a database table. Use the.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
JavaScript Part 9 George Mason University June 23, 2010.
ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState.
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.
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.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
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.
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)
(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
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
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.
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.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
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.
Cookies in PHP CPTE 212 4/7/2015 John Beckett. Two Types of Cookies A cookie is data saved on the client computer Temporary – saved in RAM in the workstation.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
Programming for the Web Cookies & Sessions Dónal Mulligan BSc MA
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.
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
ITM 352 Cookies.
COOKIES.
Web Programming Language
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.
Cookies Cookie :- A cookie is often used to identify a user. A cookie is often used to identify a user. A cookie is a small file that the server embeds.
This presentation document has been prepared by Vault Intelligence Limited (“Vault") and is intended for off line demonstration, presentation and educational.
CSc 337 Lecture 27: Cookies.
Web Programming Language
CSc 337 Lecture 25: Cookies.
Presentation transcript:

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 security threat  Today many web sites use cookies and today’s browser’s are configured to accept cookies by default 2

 Site personalization  E.g. ◦ Record name of returning visitor ◦ Keep track of shopping cart materials ◦ Register preferences 3

4 Address target market with some accuracy Help to determine the services that should be provided to the user Help inform changes to the web site Since cookies persist on the client’s computer, space does not need to be allocated on the web server to store user-specific information. Cookies can save small amounts of information for very long periods of time.

 Users can choose to configure their browsers not to accept cookies.  Cookies are unable to save large objects, arrays, or other complex data types.  Visitors to your site can delete cookies from there machines.  User may have multiple machines. 5

6

7

 Setting Cookies  Create a string in the form: cookie_name=value;  This sets the document.cookie property to that value 8

 Cookie values must never have spaces, commas, or semicolons.  The following functions will code and decode your properties: ◦ they are escape() ◦ and unescape() 9

Cookie1 function setCookie1()// write a function to set a cookie that is called on the event in the body { var name = prompt("What's your name?","");// variable name is equal to the value entered into the prompt box var cookie1 = escape("username:" + name);// declares a variable called cookie1 equal to username and name value, ESCAPE METHOD ENCRYPTS THE VALUES IN THE () document.cookie = cookie1;//SETS the cookie equal to the variable value set in the previous line } Click here to set a cookie Then click here to see an example of the cookie being read. 10

 Once you have set a cookie value you can then read it. 11

Cookie1 function readCookie1() //readCookie1 function called onclick in the body of the code { var cookie1= document.cookie; //we know there is a cookie set on our site so we need to access it var cookie1 = unescape(cookie1);//remove the padding from the cookie OR DECRYPT VALUES SET var breakcookie = cookie1.split(":");//split the cookie at the colon to access individual values var name = breakcookie[1]; //grabs the variable value after the colon, the breakcookie array starts at breakcookie[0] which would return username, //to access the value held in name variable we must refer to the second array element- breakcookie[1] alert("Your name is: " + name); //alert box returns the original value set by the cookie } Click here to set a cookie 12

 To store cookies between browser sessions, they must be given an expiry date which will control how long the browser holds it before clearing it from the cookie file. 13

var expires= new Date(); expires.setTime(expires.getTime() * 60 * 60 * 20 * days); ◦ Or var date1 = new Date("January 15, 2013"); var cookiedate = date1.toGMTString(); 14

 Adding expires=date to the cookie string and separating the different cookie components with a semicolon.  When this cookie is set, it will live on the user's hard drive until the expiration date. 15

 The expiration date also allows you to delete cookies you do not want users to have any more.  If you set the expiration date of a cookie to a time that has already passed, the cookie will be deleted from the cookie file. 16

Cookie1 function setCookie1() // write a function to set a cookie that is called on the event in the body { var name = prompt("What's your name?",""); // variable name is equal to the value entered into the prompt box var date1 = new Date("March 15, 2012"); //sets cookie expiry property to date above var cookiedate = date1.toGMTString(); var cookie1 = escape(name); // declares a variable called cookie1 document.cookie = cookie1 + cookiedate; //sets the cookie equal to the variable value set in the previous line } Click here to set cookie1 Then click here to see an example of the cookie being read.

Cookie1 function readCookie1() //readCookie1 function called onclick in the body of the code { var cookie1= document.cookie; var cookie1 = unescape(cookie1); //unescape function moves padding added when cookie was set var breakcookie = cookie1.split(); var name = breakcookie[0]; //grabs the variable value after the colon, the breakcookie array starts at breakcookie[0] which would return username, //to access the value held in name variable we must refer to the second array element- breakcookie[1] alert("Your cookie is: " + name); //alert box returns the original value set by the cookie } Click here to read cookie1

  cles/browse/cookie_1.shtml cles/browse/cookie_1.shtml  x x