JavaScript Handling Cookies, JavaScript Tutorial, Global Guide Line Technology.
Bookmark Bookmark: JavaScript Handling Cookies, JavaScript Tutorial Forum | Blog |

      Home                    

Basic JavaScript Guide.
 JScript Introduction.            
 JScript Why?                       
 JScript Recognitions.          
 JScript onMouseover.         
 JScript with Buttons.           
 JScript Alerts.                     
 JScript Variables.               
 JScript Operators.               
 JScript Functions.               
 JScript Prompts.                 
 JScript Conditions.             
 JScript Validations.            
 JScript Confirmation Boxes.
 JScript Browser Detection.  
 JScript Redirection.            
 JScript on Links.                 
 JScript Switch.                    
 JScript Loops.                     
 JScript Events.                    
 JScript Exception Handling.
 JScript Reserve Characters. 
 JScript with Objects.            
 JScript Math Object.           
 JScript using Dates.             
 JScript using String.            
 JScript using Arrays.            
 JScript Operations.              
 JScript Handling Cookies.
 JScript in Mapping.             
 JScript Time Out.                
 JScript Summary.                

JavaScript Tutorial >> JavaScript Handling Cookies.


     Back             Next     


What is a JavaScript cookie?

JavaScript Cookies writing is a technique that enables a web site owner to store information about a given user for submission in a form, or so manipulation at a later browsing session by the same use. Being that JavaScript cookies are stored on the user's machine mean on client-side, they do not present a fail-safe way to handle information, but they are essential in accomplishing this task in situations where the web programmer does not have access so server-side programming and scripting plate forms such as ASP, JSP and PHP.

A JavaScript cookie is a piece of data stored by a web browser on a user's hard disk. JavaScript cookie storage is rigidly controlled for security purposes, and the amount of data that can be stored which varies between browsers is small - typically 4K bytes per JavaScript cookie.

Hiding JavaScript cookies

JavaScript cookies are useful, but they're also unreliable. Some users set their web browsers not to accept JavaScript cookies, and cookies can 'disappear' from a disk for a variety of reasons, including space limitations or the user switching to a different web browser. JavaScript cookies should never be used to store irreplaceable data, and JavaScript cookie-handling code should always be defensive, i.e. able to handle situations where an expected JavaScript cookie isn't found.

Cookies Handling in JavaScript

Using JavaScript, we can create and use cookies direct from web pages. This is called 'client-side' cookie handling because the code runs in the browser, or 'client', as opposed to server-side JavaScript cookie handling, where code running on the web server sends cookie-handling instructions to the browser. The code here will runs on Microsoft and Netscape browsers from version 3.0 onwards, as well as other compatible browsers such as Opera.

Properties of JavaScript Cookies

JavaScript Cookie Property Description of JavaScript Cookie Example of JavaScript Cookie
name=value This sets both the JavaScript cookie's name and its value. username=scott
expires=date This optional value sets the date that the JavaScript cookie will expire on. The date should be in the format returned by the toGMTString() method of the Date object. If the expires value is not given, the JavaScript cookie will be destroyed the moment the browser is closed. expires=
13/06/2003 00:00:00
path=path This optional value specifies a path within the site to which the cookie applies. Only documents in this path will be able to retrieve the JavaScript cookie. Usually this is left blank, meaning that only the path that set the JavaScript cookie can retrieve it. path=/JavaScript
_Tutorial/
domain=domain This optional value specifies a domain within which the JavaScript cookie applies. Only websites in this domain will be able to retrieve the cookie. Usually this is left blank, meaning that only the domain that set the cookie can retrieve it. domain=
globalguideline.com
secure This optional flag indicates that the browser should use SSL when sending the JavaScript cookie to the server. This flag is rarely used. secure

How to create and retrieve JavaScript cookies


     Back             Next     
 

Examples of JavaScript Windows Object



[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright 2005 -  2018 www.globalguideline.com All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 236 visitors are online now