Cookies and Other Client-Side Storage Techniques. Bok, Jong Soon

Similar documents
Lecture 9a: Sessions and Cookies

Bok, Jong Soon

Browser Guide for PeopleSoft

5/19/2015. Objectives. JavaScript, Sixth Edition. Saving State Information with Query Strings. Understanding State Information

Beginning HTML. The Nuts and Bolts of building Web pages.

Clear Cache Guide Click here for Windows guide Click here for Mac OS guide

INTERNET ENGINEERING. HTTP Protocol. Sadegh Aliakbary

APEX Unplugged Building Oracle Application Express Applications That Can Survive Without the Internet. Dan McGhan Senior Technical Consultant

CS144: Sessions. Cookie : CS144: Web Applications

Inline HTML Editor does not load preventing typing in text field

HTML5 MOCK TEST HTML5 MOCK TEST I

CS 5450 HTTP. Vitaly Shmatikov

Step 4 Part F - How to Download a Video on YouTube and Delete a Video

Proxying. Why and How. Alon Altman. Haifa Linux Club. Proxying p.1/24

CMSC 332 Computer Networking Web and FTP

Browser Support Internet Explorer

etrac Guide System Requirements Global DMS, 1555 Bustard Road, Suite 300, Lansdale, PA , All Rights Reserved.

Instructor s Notes Web Data Management Web Client/Server Concepts. Web Data Management Web Client/Server Concepts

Republicbank.com Supported Browsers and Settings (Updated 03/12/13)

Recommended Browser Settings for Self Service Applications Revised: 10/10/2013 vmc

COMS 469: Interactive Media II

Elevate Web Builder Modules Manual

Lab 2. All datagrams related to favicon.ico had been ignored. Diagram 1. Diagram 2

Lecture 6 Application Layer. Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

Web, HTTP and Web Caching

COSC 2206 Internet Tools. The HTTP Protocol

1-1. Switching Networks (Fall 2010) EE 586 Communication and. September Lecture 10

Review of Previous Lecture

Skill Area 209: Use Internet Technology. Software Application (SWA)

HyperText Transfer Protocol

INTERNET BROWSER SETUP FOR CTC WEB FORMS INTERNET EXPLORER FIND YOUR VERSION

CS 43: Computer Networks. Layering & HTTP September 7, 2018

Version of 22 OCBC Bank. All Rights Reserved

HTTP Reading: Section and COS 461: Computer Networks Spring 2013

Lecture 7b: HTTP. Feb. 24, Internet and Intranet Protocols and Applications

How to clear a web browsers cache, cookies and history last updated on 8/28/2013

Learning Center Computer and Security Settings

Browser Cookie Settings

A. Outlook Web App -

Secure Internet File Transfer (SIFT) HTTPS User Guide. How to send and receive files via HTTPS using SIFT

How to Install (then Test) the NetBeans Bundle

Development of Web Applications

An Introduction to Google Chrome

PubMed s My NCBI can help. Are you drowning in a Sea of Publications trying to keep up with the new the journal literature?

Accessing Carolinas Healthcare System Resources Remotely

Step 5 How to download free Music from YouTube You need a YouTube account to download free Music from YouTube. If you don t have a YouTube account,

Cookies, sessions and authentication

Browser-Related Issues Clearing Cookies and Cache

Recipient USER GUIDE

JOE WIPING OUT CSRF

Instructions For Configuring Your Browser Settings and Online Banking FAQ's

s642 web security computer security adam everspaugh

Clearing Cache for NAVBLUE Web App

CSE 154 LECTURE 21: COOKIES

CSE 154 LECTURE 21: COOKIES

Chapter 2: outline. 2.6 P2P applications 2.7 socket programming with UDP and TCP

JOE WIPING OUT CSRF

Catching Events. Bok, Jong Soon

Variables and Typing

Web Mechanisms. Draft: 2/23/13 6:54 PM 2013 Christopher Vickery

Bell County District Attorney. E-Discovery Portal. Quick Guide for Attorneys. 3/17/2014 Version 1.2

Evidence.com May 2017 Release Notes

BROWSERS OPTIMIZATION

E-statement Settings Guide

Using VMware Identity Manager Apps Portal

Instructions for Configuring Your Browser Settings and Online Security FAQ s

Lesson 4: Web Browsing

Lab 4: create a Facebook Messenger bot and connect it to the Watson Conversation service

TxEIS System Requirements

Persistence & State. SWE 432, Fall 2016 Design and Implementation of Software for the Web

How to Setup & Use the Direct Traffic Features in CPV Lab

FITECH FITNESS TECHNOLOGY

Recommended Browser Settings

Creating HTML files using Notepad

2015 Beta 2 Tutorials

CS 43: Computer Networks. HTTP September 10, 2018

Common Technical Issues... 2

GET /index.php HTTP/1.1 Host: User- agent: Mozilla/4.0

Real Life Web Development. Joseph Paul Cohen

Luther Consulting, LLC August 2015 All rights reserved. Enabling Pop-ups in EvaluationWeb

Enter your Appserv username and password to sign in to the Website

Custom Embedded Tabs, on page 1 Configure Cisco Jabber for Android on Chromebook, on page 8 Cisco Jabber Mobile App Promotion, on page 9

Application Layer Introduction; HTTP; FTP

End User Manual. theicn.org/elearning-how-to

A Guide to Liv-ex Software Development Kit (SDK)

VMware Workspace Portal End User Guide

Browser Settings. Updated 4/30/ SSF

Table of Content. Last updated: June 16th, 2015

Student & Client Support Services Student Guide

TIBCO LiveView Web Getting Started Guide

Creating a Bookmark/Link for the Portal(my.cuw.edu)

dox42 Azure Active Directory Integration

Get ready for mycourses

SharePoint Guide for Reviewers

October 15. Tips for. Google Drive. Tips to expand your sharing and collaboration capabilities. Training

Portal User Guide. Best practice tips and shortcuts Icon Legend Informational notes about functions. Important warnings about a function

SC/CSE 3213 Winter Sebastian Magierowski York University CSE 3213, W13 L8: TCP/IP. Outline. Forwarding over network and data link layers

Open Mic Webcast. IBM Verse Offline Yingle Jia, Mark Wallace April 20, 2016

Offline-first PWA con Firebase y Vue.js

Offline First. HTML5 technologies for a faster, smarter, more engaging web. draft John Allsopp, Web Directions

Transcription:

Cookies and Other Client-Side Storage Techniques Bok, Jong Soon javaexpert@nate.com www.javaexpert.co.kr

HTML5 Feature Areas

Offline and Storage

Offline and Storage (Cont.) Source : Google,Introduction to HTML5, Oct. 7, 2009

Offline Web Applications Use complete web sites (documentation sets) in offline mode. Cache pages that have not been visited yet. Browsers cache data in an Application Cache. HTML5 allows online and offline detection. Allows prefetching of site resources. (can speed up pages) Simple manifest mechanism.

Example appcache File appcache File CACHE MANIFEST # manifest version 1.0.1 # Files to cache index.html cache.html html5.css image1.jpg img/foo.gif http://www.example.com/styles.css # Use from network if available NETWORK: network.html # Fallback content FALLBACK: / fallback.html

Example manifest Attribute HTML Reference the manifest file: Use.appcache extension (*.manifest also allowed) Add as attribute to HTML element <!DOCTYPE html> <html manifest="offline.appcache"> <head> <title>html5 Application Cache Rocks!</title> http://appcachefacts.info/

Web and DB Storage Many powerful new client-side storage options Web and Web Database storage a.k.a. "cookies on steroids Web Storage (Session and Local Storage) Web Database Storage Cookies Session Local Database

What is a Cookie? The original name came from the term magic cookie - a token passed between two programs. Also known as an HTTP cookie, web cookie, or browser cookie. Is a small piece of data(a variable) sent from a website and stored in a user's web browser while the user is browsing that website. Every time the user loads the website, the browser sends the cookie back to the server to notify the website of the user's previous activity.

What is a Cookie? (Cont.)

Setting a cookie Transfer of Web pages follows the HTTP. Regardless of cookies, browsers request a page from web servers by sending them a usually short text called HTTP request. To access the page http://www.example.org/index.html, browsers connect to the server www.example.org sending it a request that looks like the following one: GET /index.html HTTP/1.1 Host : www.example.org browser server

Setting a cookie (Cont.) The server replies by sending the requested page preceded by a similar packet of text, called HTTP response. This packet may contain lines requesting the browser to store cookies: HTTP/1.0 200 OK Content-type: text/html Set-Cookie: name=value Set-Cookie: name2=value2; Expires=Wed, 09 Jun 2021 10:18:14 GMT (content of page) browser server

Setting a cookie (Cont.) The server sends lines of Set-Cookie only if the server wishes the browser to store cookies. For example, the browser requests the page http://www.example.org/spec.html by sending the server www.example.org a request like the following: GET /spec.html HTTP/1.1 Host: www.example.org Cookie: name=value; name2=value2 Accept: */* browser server

Storing and Reading Cookies Cookies are accessible, like most other browser elements, through the document object. To create a cookie, you ll need to provide a cookie name, or key, an associated value, a date when it expires, and a path associated with the cookie. To access a cookie, you access the document.cookie value and then parse the cookie out.

Storing and Reading Cookies (Cont.) To create a cookie, just assign the document.cookievalue a string with the following format: document.cookie="cookiename=cookieva lue; expires=date; path=path ;

Storing and Reading Cookies (Cont.) Use cookie names starting with a dollar sign ($cookiename), with an underscore (_cookiename), and with other characters. Use only primitive types (string, boolean, and number) that convert cleanly to strings. Also can use JavaScript Object Notation (JSON) conversion to set and retrieve complex objects in cookies, refer to http://www.oreillynet.com/onlamp/blog/2008/05/dojo_good ness_part_8_jsonified.html.

Storing and Reading Cookies (Cont.) The expiration date must be in a specific GMT (UTC) format. Creating a date object and then using the togmtstring is sufficient to ensure that the date works. If no date is provided, the cookie is considered session-only - is eliminated as soon as the browser session ends.

Storing and Reading Cookies (Cont.) The cookie path is especially important. The domain and path are compared with the page request, and if they don t sync up, the cookie can t be accessed or set. This prevents other sites from accessing any and all cookies set on your browser, though this security has been circumvented in the past.

Storing and Reading Cookies (Cont.) A path setting of path=/sets the cookie s allowable path to the top-level directory at your domain. If you access the page at http://somedomain.com, this means the cookie is accessible by any subdirectory off of http://somedomain.com. If you specify a subdirectory, such as path=/images, the cookie is accessible only from web pages in this subdirectory.

Storing and Reading Cookies (Cont.) The following code snippet shows an example of a JavaScript function: Getting the cookie is not as easy because all cookies get concatenated into one string, separated by semicolons on the cookie object. var1=somevalue; var2=3.55; var3=true

Storing and Reading Cookies (Cont.)

Storing and Reading Cookies (Cont.) To erase the cookie, eliminate its value or set the date to a past date, or do both, as the following JavaScript function demonstrates: The next time the document cookie string is accessed, the cookie will no longer exist.

Storing and Reading Cookies (Cont.) Before you use any cookie functionality, it s best to first test to make sure cookies are implemented and enabled for the browser. To check whether cookies are enabled if (navigator.cookieenabled)... Note that not all browsers return the correct value when testing the cookieenabled property.

Lab1 : Setting, reading, and erasing cookies Web Browsers IE10, Firefox, Google Chrome, Opera, Safari Text Editors Notepad++ or Editplus Files cookie.html

Lab1 : cookie.html (1/2)

Lab1 : cookie.html )2/2)

Lab1 : Result