XP Tutorial 9 New Perspectives on JavaScript, Comprehensive1 Working with Cookies Managing Data in a Web Site Using JavaScript Cookies.

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
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.
Tutorial 6 Creating a Web Form
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.
Tutorial 6 Working with Web Forms
Tutorial 10 Programming with JavaScript
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
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.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
Client-Side programming with JavaScript 3
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
Cookies Set a cookie – setcookie() Extract data from a cookie - $_COOKIE Augment user authentication script with a cookie.
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.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
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.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
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.
Web Programming Language Week 7 Dr. Ken Cosh Security, Sessions & Cookies.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Week seven CIT 354 Internet II. 2 Objectives Database_Driven User Authentication Using Cookies Session Basics Summary Homework and Project 2.
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Regular Expression (continue) and Cookies. Quick Review What letter values would be included for the following variable, which will be used for validation.
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.
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
Session and Cookie Management in.Net Sandeep Kiran Shiva UIN:
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
7 Chapter Seven Client-side Scripts. 7 Chapter Objectives Create HTML forms Learn about client-side scripting languages Create a client-side script using.
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.
The Web Wizard’s Guide To JavaScript Chapter 7 Cookies: Maintaining State.
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
Persistence Maintaining state using cookies and queries.
Cookies (continue). Extracting Data From Cookies Data retrieved from a cookie is a simple text string. While there is no specific JavaScript function.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
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.
IS2802 Introduction to Multimedia Applications for Business Lecture 8: JavaScript and Cookies Rob Gleasure
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
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.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
Project 5: Customizing User Content Essentials for Design JavaScript Level Two Michael Brooks.
ASP.NET Part II Dr. Awad Khalil Computer Science Department AUC.
Tutorial 6 Creating a Web Form
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
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 ©
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.
Presentation transcript:

XP Tutorial 9 New Perspectives on JavaScript, Comprehensive1 Working with Cookies Managing Data in a Web Site Using JavaScript Cookies

XP Tutorial 9New Perspectives on JavaScript, Comprehensive2 Objectives Understand the history of cookies Know the advantages and disadvantages of using cookies Understand the parts of a cookie Create a cookie for a first-time Web site visitor

XP Tutorial 9New Perspectives on JavaScript, Comprehensive3 Objectives Manage the display of a personal greeting to users returning to a site Control the process of creating bulk cookies for use in a shopping cart Manage the deletion of cookies used in a shopping cart application

XP Tutorial 9New Perspectives on JavaScript, Comprehensive4 Objectives Manage the flow of form data using cookies Manage cookies used to create a form feedback page Control the deletion of cookies used in a form

XP Tutorial 9New Perspectives on JavaScript, Comprehensive5 Introducing Cookies Features of Patti’s Web site –Users should be able to Navigate product listing Purchase products Create accounts

XP Tutorial 9New Perspectives on JavaScript, Comprehensive6 Functions of Patti’s Web Pages

XP Tutorial 9New Perspectives on JavaScript, Comprehensive7 Developing a Shopping Cart Application Back end –Mechanism that helps Web site function behind the scenes Front end –Visible part of a Web site

XP Tutorial 9New Perspectives on JavaScript, Comprehensive8 Developing a Shopping Cart Application Server-side shopping cart –Shopping cart application controlled via server Client-side shopping cart –Application controlled via user’s browser with JavaScript

XP Tutorial 9New Perspectives on JavaScript, Comprehensive9 Client-Side and Server-Side Shopping Cart Applications

XP Tutorial 9New Perspectives on JavaScript, Comprehensive10 Understanding Cookies Session –Each visit to a Web page by a user Cookie –Text file that stores data from a user’s interaction with a specific Web site –Persistent Stateless protocol –No way to track information

XP Tutorial 9New Perspectives on JavaScript, Comprehensive11 Understanding Cookies Client-side cookie –Initiated by a page coming from a Web server –Created in a browser’s memory Server-side cookie –Created and stored on a server using server-side scripting languages Privacy statement –Explains how Web site protects privacy of those who visit and provide information

XP Tutorial 9New Perspectives on JavaScript, Comprehensive12 Types of Cookies First-party cookie –Cookie created from the Web site you are visiting Third-party cookie –Cookie created at different Web site and is then sent to Web site you are currently visiting

XP Tutorial 9New Perspectives on JavaScript, Comprehensive13 Types of Cookies Unsatisfactory cookie –Cookie that might allow access to personally identifiable information without your knowledge Compact privacy policy –Code sent to a user’s browser that identifies the nature of a cookie

XP Tutorial 9New Perspectives on JavaScript, Comprehensive14 Customized Cookie Settings in Internet Explorer

XP Tutorial 9New Perspectives on JavaScript, Comprehensive15 Creating a Cookie Syntax document.cookie = "name = value; expires = expiration; path = path; domain = domain; secure";

XP Tutorial 9New Perspectives on JavaScript, Comprehensive16 Cookie Attributes

XP Tutorial 9New Perspectives on JavaScript, Comprehensive17 The name and value Properties Each cookie stores –Single piece of information as its value, which is paired with a name when cookie is created Dynamically generating parameters for cookie username = document.form1.uname.value; document.cookie = "input1 = "+username;

XP Tutorial 9New Perspectives on JavaScript, Comprehensive18 The expires Property Cookie –Can be assigned an expiration date To assign expiration date expires = Day, DD-Mmm-YY HH:MM:SS GMT Per session cookie –Exists only for as long as the browser is communicating with the Web site

XP Tutorial 9New Perspectives on JavaScript, Comprehensive19 The path Property By default –Cookie available only to page where it originated path attribute –Used to set the pages to which a cookie is available

XP Tutorial 9New Perspectives on JavaScript, Comprehensive20 The domain Property Used to specify –URL of domain to which you want to make cookie available If no value is specified for domain property –Its value is set to the server of origin

XP Tutorial 9New Perspectives on JavaScript, Comprehensive21 The secure Property The final property you can set for a cookie Enables you to specify that –Cookie is to be transmitted over the HTTPS protocol To set a cookie as a secure cookie –Add the parameter “secure” without a value

XP Tutorial 9New Perspectives on JavaScript, Comprehensive22 Working with Cookie Values Patti’s Web site –Designed so that user input is first checked using validation script named checkForm() checkForm() verifies that user –Completed the form fields –Entered the same password twice

XP Tutorial 9New Perspectives on JavaScript, Comprehensive23 Extracting Cookie Values

XP Tutorial 9New Perspectives on JavaScript, Comprehensive24 Populating Form Fields with Cookie Values Assigning value of user variable to username field function retrieveAccount() { document.login.username.value=user; }

XP Tutorial 9New Perspectives on JavaScript, Comprehensive25 Using Cookie Values to Create a Personalized Greeting Code to personalize the home page if((fn != "")&&(ln != "")){document.write("Hello, "+fn+" "+ln+". ")}

XP Tutorial 9New Perspectives on JavaScript, Comprehensive26 Implementing a Shopping Cart New requirements for Web site –Expand site’s use of cookies to add shopping cart functionality –When user selects an item Item’s name, price information, and quantity should be placed in cart –Users should be able to enter quantity in text box –Users should be able to receive immediate feedback

XP Tutorial 9New Perspectives on JavaScript, Comprehensive27 Shopping Cart Solution Using all Available Cookies

XP Tutorial 9New Perspectives on JavaScript, Comprehensive28 Shopping Cart Solution Minimizing Cookie Use

XP Tutorial 9New Perspectives on JavaScript, Comprehensive29 Code to Create Cookies Containing Data on Each Product

XP Tutorial 9New Perspectives on JavaScript, Comprehensive30 Displaying Shopping Cart Contents showOrder() function –Extracts substrings from the cookie value –Totals the cost of each product ordered –Displays total cost just below list of items in the shopping cart –Creates dynamic table with rows and columns to support displaying data

XP Tutorial 9New Perspectives on JavaScript, Comprehensive31 Shopping Cart Display

XP Tutorial 9New Perspectives on JavaScript, Comprehensive32 Form Control Using Cookies Additional requirement for Web site –Feedback form that Allows users to verify information entered on the patti_cart.htm page

XP Tutorial 9New Perspectives on JavaScript, Comprehensive33 Preview of the Form Feedback Page

XP Tutorial 9New Perspectives on JavaScript, Comprehensive34 Preserving Form Data Process of collecting and saving form data –To be used later in functioning of Web site during the current session or –For retrieval at a later date in a future session makeFormCookie() function –Performs the preserving form data process

XP Tutorial 9New Perspectives on JavaScript, Comprehensive35 Process of Preserving Form Data on Patti’s Web Site

XP Tutorial 9New Perspectives on JavaScript, Comprehensive36 The makeFormCookie() Function

XP Tutorial 9New Perspectives on JavaScript, Comprehensive37 Creating a Form Feedback Page Form feedback page allows users to –Review their input from the form –Verify that input is accurate

XP Tutorial 9New Perspectives on JavaScript, Comprehensive38 Code to Change Null Values to Empty Strings

XP Tutorial 9New Perspectives on JavaScript, Comprehensive39 Code to Retrieve Cookie Values and Pass them to Individual Variables

XP Tutorial 9New Perspectives on JavaScript, Comprehensive40 The Completed Form Feedback Page for Patti’s Web Site

XP Tutorial 9New Perspectives on JavaScript, Comprehensive41 Deleting Cookies To control deletion of cookies –Set date and time you want cookie deleted –Develop function that deletes cookie when it is called To expire cookies on Patti’s Web site –Create function named zapOrder()

XP Tutorial 9New Perspectives on JavaScript, Comprehensive42 Code for the zapOrder() Function

XP Tutorial 9New Perspectives on JavaScript, Comprehensive43 The Confirmation Page of Patti’s Web Site