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.

Slides:



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

UFCE8V-20-3 Information Systems Development 3 (SHAPE HK)
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.
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.
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.
HTTP Cookie CSC 667/867. PERSISTENT CLIENT STATE HTTP COOKIES Cookies are a general mechanism which server side connections (such as CGI scripts) can.
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.
Chapter 10 Managing State Information PHP Programming with MySQL.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Chapter 10 Maintaining State Information Using Cookies.
Objectives Learn about state information
Client-Side programming with JavaScript 3
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
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 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Principles of Computer Security: CompTIA Security + ® and Beyond, Third Edition © 2012 Principles of Computer Security: CompTIA Security+ ® and Beyond,
CSC 2720 Building Web Applications Cookies, URL-Rewriting, Hidden Fields and Session Management.
Cookies and Security Saving the “state”
JavaScript, Fourth Edition
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
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.
Web Programming Language Week 7 Dr. Ken Cosh Security, Sessions & Cookies.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Regular Expression (continue) and Cookies. Quick Review What letter values would be included for the following variable, which will be used for validation.
1 CS 21A Beginning JavaScript Programming Project 4 Cookies, Arrays, and Frames Sonny Huang.
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.
PHP Programming with MySQL Slide 10-1 CHAPTER 10 Managing State Information.
7 Chapter Seven Client-side Scripts. 7 Chapter Objectives Create HTML forms Learn about client-side scripting languages Create a client-side script using.
Web Metrics Terminology & Measurement. Visit A visit is a Web user with a unique address entering a Web site at some page for the first time that day.
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
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.
Chapter 4: Working with ASP.NET Server Controls OUTLINE  What ASP.NET Server Controls are  How the ASP.NET run time processes the server controls on.
The Web Wizard’s Guide To JavaScript Chapter 7 Cookies: Maintaining State.
JavaScript Part 9 George Mason University June 23, 2010.
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.
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
Persistence Maintaining state using cookies and queries.
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.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Scripting Languages Client Side and Server Side. Examples of client side/server side Examples of client-side side include: JavaScript Jquery (uses a JavaScript.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
(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)
 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 time the same computer requests.
IS2802 Introduction to Multimedia Applications for Business Lecture 8: JavaScript and Cookies Rob Gleasure
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.
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.
Programming for the Web Cookies & Sessions Dónal Mulligan BSc MA
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.
Implementing Cookies in PHP
Cookies and JavaScript
Advanced Concepts and AJAX
Presentation transcript:

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 users return to the site at a later time.

Cookie Cookies are little bits of information that you can leave on a user's hard drive, where they stay even after the user leaves your site or turns off the computer, which is extremely useful when you want to remember information about visitors.

How Cookies can be created? (1) By client-side script in a HTML page (2) Win32 programs that use the Microsoft Win32 Internet functions, (3) By server-side script (for example, [ASP] page, Common Gateway Interface [CGI] script, PHP, ASP.NET etc….)

Cookies allow you to give your pages a personal touch. For instance, With a cookie you can "remember" people's names and show warm greeting every time they re-visit. You can also remember user preferences — if a visitor generally comes in on a slow connection, a cookie lets you know to automatically serve them minimal graphics.

The most important limitations for cookie are:  Not everyone has a cookie-friendly browser (but most do).  Not everyone who has a cookie- friendly browser will accept your cookies (but most will).  Not everyone who has a cookie- friendly browser will accept your cookies (but most will).  Each domain is allotted only 20 cookies, so use them sparingly.  Cookies must be no larger than 4 KB. That's just over 4,000 characters, which is plenty.

Cookies Structure Cookies are always stored in “name=value” format. Setting Cookies To set cookie we have to create a string in the form of cookie_name=value and then set the document.cookie property to that. Cookie values cannot have spaces, commas, or semicolons.

<html><head> function setCookie() { function setCookie() { var the_name=prompt("What's your name?","") var the_cookie = "wm_javascript=" + escape("username:" + the_name); document.cookie = the_cookie; alert("Thanks, now go to the next page."); }

function readCookie() { var the_cookie = document.cookie; var the_cookie = unescape(the_cookie); var broken_cookie = the_cookie.split(":"); var the_name = broken_cookie[1]; alert("Your name is: " + the_name); } setCookie() readCookie()

escape and unescape methods var str1="How are you?" document.write("Encode :" + escape(str1)) document.write("Decode :" +unescape(str1)) Output: Encode:How%20are%20you%3F Decode:How are you?

The name/value pair must not contain any white space characters, commas, or semicolons. Using such characters can cause the cookie to be truncated or even discarded. When you assign a new cookie value to document.cookie, the current cookies are not replaced. The new cookie is parsed and its name/value pair is appended to the list. If we use same name, path and domain then previous cookie is replaced by new cookie. The syntax for setting cookies is:

Name=value[;expires=date][;domain=dom ain][;path=path][;secure] To set expire date use toGMTString() method of Date instances. ToGMTString creates following date structure. Expire=Sun,12-Dec :50:00 GMT Domain option specifies for which domain cookie is valid. For example, Domain=

Path indicates the subset of paths at the domain for which the cookie will be returned. path=/books/js/. Secure indicates that the cookie is only to be returned over a secure HTTPS connection.