JavaScript DHTML/Development/Cookie

Материал из Web эксперт
Перейти к: навигация, поиск

A Cookie Example

   <source lang="html4strict">
 

/* JavaScript Unleashed, Third Edition by Richard Wagner and R. Allen Wyke ISBN: 067231763X Publisher Sams CopyRight 2000

  • /

<html> <head> <script language="JavaScript">

</script> </head> <body> <script language="JavaScript">

</script>

This is a very dull page unless you have a JavaScriptenabled browser.

</body> </html>


 </source>
   
  


A Cookie Test Program

   <source lang="html4strict">
 

<HTML> <HEAD> <TITLE>Cookie Test</TITLE> <SCRIPT LANGUAGE="JavaScript"></SCRIPT> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript">

document.write("Your current cookie value is: ""+ document.cookie+""")

</SCRIPT> <FORM ACTION="" NAME="form1">

Enter new cookie: <INPUT TYPE="TEXT" SIZE="60" NAME="cookie">

<INPUT TYPE="BUTTON" NAME="setCookie" VALUE="Set Cookie" onClick="updateCookie()"> </FORM> </BODY> </HTML>



 </source>
   
  


A Website Access Counter

   <source lang="html4strict">
 

/* Mastering JavaScript, Premium Edition by James Jaworski ISBN:078212819X Publisher Sybex CopyRight 2001

  • /

<HTML> <HEAD> <TITLE>Keeping track of Web site access</TITLE> <SCRIPT LANGUAGE="JavaScript" ></SCRIPT> </HEAD> <BODY BGCOLOR="#FFFFFF"> <SCRIPT LANGUAGE="JavaScript"></SCRIPT>

Keeping track of Web site access

</body> </HTML>


 </source>
   
  


Bill Dortch"s Cookie Functions

   <source lang="html4strict">
 

/* JavaScript Bible, Fourth Edition by Danny Goodman Publisher: John Wiley & Sons CopyRight 2001 ISBN: 0764533428

  • /

<html> <head> <title>Cookie Functions</title> </head> <body> <script language="javascript">

</script> </body> </html>



 </source>
   
  


"cookieEnabled" Example

   <source lang="html4strict">
 
   

<html> <body> <button onClick="alert(navigator.cookieEnabled);">Are Cookies Enabled</button> </body> </html>



 </source>
   
  


Cookie install and delete (remove)

   <source lang="html4strict">
 

/* Examples From JavaScript: The Definitive Guide, Fourth Edition Legal matters: these files were created by David Flanagan, and are Copyright (c) 2001 by David Flanagan. You may use, study, modify, and distribute them for any purpose. Please note that these examples are provided "as-is" and come with no warranty of any kind. David Flanagan

  • /

<html> <script language="JavaScript1.1"> // The constructor function: creates a cookie object for the specified // document, with a specified name and optional attributes. // Arguments: // document: The Document object that the cookie is stored for. Required. // name: A string that specifies a name for the cookie. Required. // hours: An optional number that specifies the number of hours from now // that the cookie should expire. // path: An optional string that specifies the cookie path attribute. // domain: An optional string that specifies the cookie domain attribute. // secure: An optional Boolean value that, if true, requests a secure cookie. // function Cookie(document, name, hours, path, domain, secure) {

   // All the predefined properties of this object begin with "$"
   // to distinguish them from other properties which are the values to
   // be stored in the cookie.
   this.$document = document;
   this.$name = name;
   if (hours)
       this.$expiration = new Date((new Date()).getTime() + hours*3600000);
   else this.$expiration = null;
   if (path) this.$path = path; else this.$path = null;
   if (domain) this.$domain = domain; else this.$domain = null;
   if (secure) this.$secure = true; else this.$secure = false;

} // This function is the store() method of the Cookie object. Cookie.prototype.store = function () {

   // First, loop through the properties of the Cookie object and
   // put together the value of the cookie. Since cookies use the
   // equals sign and semicolons as separators, we"ll use colons
   // and ampersands for the individual state variables we store 
   // within a single cookie value. Note that we escape the value
   // of each state variable, in case it contains punctuation or other
   // illegal characters.
   var cookieval = "";
   for(var prop in this) {
       // Ignore properties with names that begin with "$" and also methods.
       if ((prop.charAt(0) == "$") || ((typeof this[prop]) == "function")) 
           continue;
       if (cookieval != "") cookieval += "&";
       cookieval += prop + ":" + escape(this[prop]);
   }
   // Now that we have the value of the cookie, put together the 
   // complete cookie string, which includes the name and the various
   // attributes specified when the Cookie object was created.
   var cookie = this.$name + "=" + cookieval;
   if (this.$expiration)
       cookie += "; expires=" + this.$expiration.toGMTString();
   if (this.$path) cookie += "; path=" + this.$path;
   if (this.$domain) cookie += "; domain=" + this.$domain;
   if (this.$secure) cookie += "; secure";
   // Now store the cookie by setting the magic Document.cookie property.
   this.$document.cookie = cookie;

} // This function is the load() method of the Cookie object. Cookie.prototype.load = function() {

   // First, get a list of all cookies that pertain to this document.
   // We do this by reading the magic Document.cookie property.
   var allcookies = this.$document.cookie;
   if (allcookies == "") return false;
   // Now extract just the named cookie from that list.
   var start = allcookies.indexOf(this.$name + "=");
   if (start == -1) return false;   // Cookie not defined for this page.
   start += this.$name.length + 1;  // Skip name and equals sign.
   var end = allcookies.indexOf(";", start);
   if (end == -1) end = allcookies.length;
   var cookieval = allcookies.substring(start, end);
   // Now that we"ve extracted the value of the named cookie, we"ve
   // got to break that value down into individual state variable 
   // names and values. The name/value pairs are separated from each
   // other by ampersands, and the individual names and values are
   // separated from each other by colons. We use the split method
   // to parse everything.
   var a = cookieval.split("&");    // Break it into array of name/value pairs.
   for(var i=0; i < a.length; i++)  // Break each pair into an array.
       a[i] = a[i].split(":");
   // Now that we"ve parsed the cookie value, set all the names and values
   // of the state variables in this Cookie object. Note that we unescape()
   // the property value, because we called escape() when we stored it.
   for(var i = 0; i < a.length; i++) {
       this[a[i][0]] = unescape(a[i][1]);
   }
   // We"re done, so return the success code.
   return true;

} // This function is the remove() method of the Cookie object. Cookie.prototype.remove = function() {

   var cookie;
   cookie = this.$name + "=";
   if (this.$path) cookie += "; path=" + this.$path;
   if (this.$domain) cookie += "; domain=" + this.$domain;
   cookie += "; expires=Fri, 02-Jan-1970 00:00:00 GMT";
   this.$document.cookie = cookie;

}

//=================================================================== // The previous code is the definition of the Cookie class. // The following code is a sample use of that class. //=================================================================== // Create the cookie we"ll use to save state for this web page. // Since we"re using the default path, this cookie will be accessible // to all web pages in the same directory as this file or "below" it. // Therefore, it should have a name that is unique among those pages. // Note that we set the expiration to 10 days in the future. var visitordata = new Cookie(document, "name_color_count_state", 240); // First, try to read data stored in the cookie. If the cookie is not // defined, or if it doesn"t contain the data we need, then query the // user for that data. if (!visitordata.load() || !visitordata.name || !visitordata.color) {

   visitordata.name = prompt("What is your name:", "");
   visitordata.color = prompt("What is your favorite color:", "");

} // Keep track of how many times this user has visited the page: if (visitordata.visits == null) visitordata.visits = 0; visitordata.visits++; // Store the cookie values, even if they were already stored, so that the // expiration date will be reset to 10 days from this most recent visit. // Also, store them again to save the updated visits state variable. visitordata.store(); // Now we can use the state variables we read: document.write("" +

              "Welcome, " + visitordata.name + "!" +
              "" +
"

You have visited " + visitordata.visits + " times."); </script> <form> <input type="button" value="Forget My Name" onclick="visitordata.remove();"> </form> </html> </source>

Cookie Preferences

   <source lang="html4strict">
 

/* JavaScript Application Cookbook By Jerry Bradenbaugh Publisher: O"Reilly Series: Cookbooks ISBN: 1-56592-577-7

  • /



 </source>
   
  

<A href="http://www.wbex.ru/Code/JavaScriptDownload/CookiePreferences.zip">CookiePreferences.zip( 183 k)</a>


Cookie: retrieve a future expiration date in proper format

   <source lang="html4strict">
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

 "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd">

<html> <head> <title>Recipe 10.04a</title> <style rel="stylesheet" id="mainStyle" type="text/css"> html {background-color:#cccccc} body {background-color:#eeeeee; font-family:Tahoma,Arial,Helvetica,sans-serif;

     font-size:12px;
   margin-left:15%; margin-right:15%; border:3px groove darkred; padding:15px}

h1 {text-align:right; font-size:1.5em; font-weight:bold} h2 {text-align:left; font-size:1.1em; font-weight:bold; text-decoration:underline} .buttons {margin-top:10px} </style> <script type="text/javascript"> /* cookies.js */ /*

    Example File From "JavaScript and DHTML Cookbook"
    Published by O"Reilly & Associates
    Copyright 2003 Danny Goodman
  • /

// utility function to retrieve a future expiration date in proper format; // pass three integer parameters for the number of days, hours, // and minutes from now you want the cookie to expire; all three // parameters required, so use zeros where appropriate function getExpDate(days, hours, minutes) {

   var expDate = new Date();
   if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") {
       expDate.setDate(expDate.getDate() + parseInt(days));
       expDate.setHours(expDate.getHours() + parseInt(hours));
       expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
       return expDate.toGMTString();
   }

} // utility function called by getCookie() function getCookieVal(offset) {

   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) {
       endstr = document.cookie.length;
   }
   return unescape(document.cookie.substring(offset, endstr));

} // primary function to retrieve cookie by name function getCookie(name) {

   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
       var j = i + alen;
       if (document.cookie.substring(i, j) == arg) {
           return getCookieVal(j);
       }
       i = document.cookie.indexOf(" ", i) + 1;
       if (i == 0) break; 
   }
   return null;

} // store cookie value with optional details as needed function setCookie(name, value, expires, path, domain, secure) {

   document.cookie = name + "=" + escape (value) +
       ((expires) ? "; expires=" + expires : "") +
       ((path) ? "; path=" + path : "") +
       ((domain) ? "; domain=" + domain : "") +
       ((secure) ? "; secure" : "");

} // remove the cookie by setting ancient expiration date function deleteCookie(name,path,domain) {

   if (getCookie(name)) {
       document.cookie = name + "=" +
           ((path) ? "; path=" + path : "") +
           ((domain) ? "; domain=" + domain : "") +
           "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }

}

</script> <script language="JavaScript" type="text/javascript"> function saveValues() {

 setCookie("name1", document.forms[0].name1.value);
 setCookie("name2", document.forms[0].name2.value);
 setCookie("color", document.forms[0].color.options[document.forms[0].color.selectedIndex].value);

} function applyValues() {

 var form = document.forms[0];
 form.name1.value = (getCookie("name1")) ? getCookie("name1") : "";
 form.name2.value = (getCookie("name2")) ? getCookie("name2") : "";
 var selValue = (getCookie("color")) ? getCookie("color") : "";
 if (selValue) {
   for (var i = 0; i < form.color.options.length; i++) {
     if (form.color.options[i].value == selValue) {
       form.color.selectedIndex = i;
       break;
     }
   }
 }

} </script> </head> <body onunload="saveValues()" onload="applyValues()"> <form>

Page One


First Name: <input type="text" name="name1" id="name1">
Last Name: <input type="text" name="name2" id="name2">
Your favorite color: <select id="color" name="color">

 <option value="">Pick a color:</option>
 <option value="Red">Red</option>
 <option value="Green">Green</option>
 <option value="Blue">Blue</option>

</select> </form> </body> </html>



 </source>
   
  


Cookie set, delete, get value and create

   <source lang="html4strict">
 

/* JavaScript Application Cookbook By Jerry Bradenbaugh Publisher: O"Reilly Series: Cookbooks ISBN: 1-56592-577-7

  • /

<HTML> <HEAD> <TITLE>cookie set, delete, get value and create</TITLE> <SCRIPT LANUAGE="JavaScript"> // cookies.js // Derived from the Bill Dortch code at http://www.hidaho.ru/cookies/cookie.txt var today = new Date(); var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000); function getCookieVal (offset) {

 var endstr = document.cookie.indexOf (";", offset);
 if (endstr == -1) { endstr = document.cookie.length; }
 return unescape(document.cookie.substring(offset, endstr));
 }

function GetCookie (name) {

 var arg = name + "=";
 var alen = arg.length;
 var clen = document.cookie.length;
 var i = 0;
 while (i < clen) {
   var j = i + alen;
   if (document.cookie.substring(i, j) == arg) {
     return getCookieVal (j);
     }
   i = document.cookie.indexOf(" ", i) + 1;
   if (i == 0) break; 
   }
 return null;
 }

function DeleteCookie (name,path,domain) {

 if (GetCookie(name)) {
   document.cookie = name + "=" +
   ((path) ? "; path=" + path : "") +
   ((domain) ? "; domain=" + domain : "") +
   "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }
 }

function SetCookie (name,value,expires,path,domain,secure) {

 document.cookie = name + "=" + escape (value) +
   ((expires) ? "; expires=" + expires.toGMTString() : "") +
   ((path) ? "; path=" + path : "") +
   ((domain) ? "; domain=" + domain : "") +
   ((secure) ? "; secure" : "");
 }

</SCRIPT> </HEAD> <BODY BGCOLOR=WHITE> <SCRIPT LANGUAGE="JavaScript">

</SCRIPT> </BODY> </HTML>


 </source>
   
  


Cookie utility function

   <source lang="html4strict">
 

/* cookies.js */ /*

    Example File From "JavaScript and DHTML Cookbook"
    Published by O"Reilly & Associates
    Copyright 2003 Danny Goodman
  • /

// utility function to retrieve a future expiration date in proper format; // pass three integer parameters for the number of days, hours, // and minutes from now you want the cookie to expire; all three // parameters required, so use zeros where appropriate function getExpDate(days, hours, minutes) {

   var expDate = new Date();
   if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") {
       expDate.setDate(expDate.getDate() + parseInt(days));
       expDate.setHours(expDate.getHours() + parseInt(hours));
       expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
       return expDate.toGMTString();
   }

} // utility function called by getCookie() function getCookieVal(offset) {

   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) {
       endstr = document.cookie.length;
   }
   return unescape(document.cookie.substring(offset, endstr));

} // primary function to retrieve cookie by name function getCookie(name) {

   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
       var j = i + alen;
       if (document.cookie.substring(i, j) == arg) {
           return getCookieVal(j);
       }
       i = document.cookie.indexOf(" ", i) + 1;
       if (i == 0) break; 
   }
   return null;

} // store cookie value with optional details as needed function setCookie(name, value, expires, path, domain, secure) {

   document.cookie = name + "=" + escape (value) +
       ((expires) ? "; expires=" + expires : "") +
       ((path) ? "; path=" + path : "") +
       ((domain) ? "; domain=" + domain : "") +
       ((secure) ? "; secure" : "");

} // remove the cookie by setting ancient expiration date function deleteCookie(name,path,domain) {

   if (getCookie(name)) {
       document.cookie = name + "=" +
           ((path) ? "; path=" + path : "") +
           ((domain) ? "; domain=" + domain : "") +
           "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }

}



 </source>
   
  


Create a cookie

   <source lang="html4strict">
 
   

<html> <body> <script language="JavaScript">

   myDate = new Date("12/22/2005 12:00 AM");
   document.cookie = "firstName=Joe; 
   expires=" + myDate.toString + ";";

</script> <button onclick="alert(document.cookie);">See Document Cookie</button> </body> </html>



 </source>
   
  


Keeping Track of User Access Time

   <source lang="html4strict">
 

/* Mastering JavaScript, Premium Edition by James Jaworski ISBN:078212819X Publisher Sybex CopyRight 2001

  • /

<HTML> <HEAD> <TITLE>Keeping track of Web site access time</TITLE> <SCRIPT LANGUAGE="JavaScript"></SCRIPT> </HEAD> <BODY BGCOLOR="#FFFFFF"> <SCRIPT LANGUAGE="JavaScript"></SCRIPT>

Keeping track of Web site access time

<P ALIGN="CENTER">[The rest of the Web page goes here.]

</BODY>


 </source>
   
  


Quiz Program base on Cookie

   <source lang="html4strict">
 

/* Mastering JavaScript, Premium Edition by James Jaworski ISBN:078212819X Publisher Sybex CopyRight 2001

  • /

<HTML> <HEAD> <TITLE>Quiz Program</TITLE> <SCRIPT LANGUAGE="JavaScript"></SCRIPT> <SCRIPT LANGUAGE="JavaScript"></SCRIPT> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript"></SCRIPT> </BODY> </HTML>


 </source>
   
  


Read all cookies

   <source lang="html4strict">

<html> <head> <title>Reading Cookie</title> <script type = "text/javascript"> var incCookies = document.cookie.split(";"); for (var c = 0; c < incCookies.length; c++) {

   var splitCookies = incCookies[c].split("=");
   if (splitCookies[0] == "cookie1") {
       alert(incCookies[c]);
   }

} </script> </head> <body>

Hello

</body> </html>

 </source>
   
  


Reads, writes and deletes current Web page"s cookies

   <source lang="html4strict">
 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML>

 <HEAD>
   <TITLE>JsLib 1.3 - Exemple - cookies.js</TITLE>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Etienne CHEVILLARD">
   <SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">

/* cookies.js

* Role : lit, ecrit et efface les cookies de la page Web courante
* Projet : JsLib
* Auteur : Etienne CHEVILLARD (echevillard@users.sourceforge.net)
* Version : 1.3
* Creation : 11/04/2001
* Mise a jour : 23/02/2005
*/

// --- Variables globales --- // vrai si le navigateur accepte les cookies var cookies_ok=false; // --- Fonctions --- // indique si le navigateur accepte les cookies function accepteCookies() {

 cookies_ok=false;
 if (navigator.cookieEnabled) {
   cookies_ok=true;
 } else {
   ecrireCookie ("jslib_cookie", "ok");
   if (lireCookie("jslib_cookie")=="ok") { cookies_ok=true; }
   effacerCookie("jslib_cookie");
 }
 return (cookies_ok);

} // fin accepteCookies() // ecrit un cookie de nom et valeur specifiees pour le nombre de jours specifie function ecrireCookie(nom, valeur, jours) {

 if (!nom || nom=="") return false;
 if (!valeur) { valeur=""; }
 if (!jours) { jours=0; }
 var expire;
 if (parseInt(jours)!=0) {
   var date=new Date();
   date.setTime(date.getTime()+(parseInt(jours)*24*60*60*1000));
   expire="; expires="+date.toGMTString();
 } else {
   expire="";
 }
 document.cookie=nom+"="+escape(valeur)+expire+"; path=/";
 return true;

} // fin ecrireCookie(nom, valeur, jours) // efface le cookie de nom specifie function effacerCookie(nom) {

 return (ecrireCookie(nom, "", -1));

} // fin effacerCookie(nom) // lit et retourne la valeur du cookie de nom specifie function lireCookie(nom) {

 if (!nom || nom=="") return ("");
 var nomEq=nom+"=";
 var tab=document.cookie.split(";");
 for(var i=0; i<tab.length; i++) {
   var cook=tab[i];
   while (cook.charAt(0)==" ")
     cook=cook.substring(1, cook.length);
   if (cook.indexOf(nomEq)==0)
     return unescape(cook.substring(nomEq.length, cook.length));
 }
 return ("");

} // fin lireCookie(nom)

   </SCRIPT>
 </HEAD>
 <BODY>

JsLib 1.3


Exemple - cookies.js

   <NOSCRIPT>

Erreur : votre navigateur ne reconnait pas le Javascript ou est configuré pour ne pas prendre en compte le code Javascript. Dans ce dernier cas, vous pouvez modifier la configuration dans les préférences/options de votre navigateur.


   </NOSCRIPT>
   <P>Votre navigateur accepte-il les cookies ?
     <SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">
       if (accepteCookies()) document.write("oui");
       else document.write("non");
     </SCRIPT>
   <P>Votre prénom est :
     <SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">
       if (accepteCookies()) {
         if (lireCookie("prenom").length < 1) {
           var reponse;
           while (!reponse) reponse = window.prompt("Veuillez saisir votre nom ou pseudonyme :", "Toto");
           ecrireCookie("prenom", reponse, 3650);
         }
         document.write(lireCookie("prenom"));
       }
     </SCRIPT>
       <FORM ACTION="GET" NAME="f1">
         <INPUT TYPE=BUTTON VALUE="Modifier mon prénom"
         onClick="effacerCookie("prenom"); window.location.reload(true);">
       </FORM>
   <P>Nombre de visites effectuées sur cette page :
     <SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">
       if (accepteCookies()) {
         if (lireCookie("visites").length < 1) {
           ecrireCookie("visites", "0", 3650);
         }
         ecrireCookie("visites", parseInt(lireCookie("visites"))+1, 3650);
         document.write(lireCookie("visites"));
       }
     </SCRIPT>
 </BODY>

</HTML>


 </source>
   
  

<A href="http://www.wbex.ru/Code/JavaScriptDownload/JsLib13.zip">JsLib13.zip( 311 k)</a>


Save name to cookie

   <source lang="html4strict">
 

<HTML> <HEAD> <SCRIPT language="JavaScript">

</SCRIPT> </HEAD> <BODY> text text text </BODY> </HTML>


 </source>
   
  


Secure cookie

   <source lang="html4strict">

<html> <head> <title>Hello Cookie</title> <script type = "text/javascript"> var cookName = "cookie2"; var cookVal = "testvalue"; var date = new Date(); date.setTime(date.getTime()+86400000); var expireDate = date.toGMTString(); var myCookie = cookName + "=" + cookVal + ";expires=" + expireDate + ";secure"; document.cookie = myCookie; </script> </head> <body>

<p>Hello

</body> </html>

 </source>
   
  


Set cookie to document and read it back

   <source lang="html4strict">
 

<HTML> <HEAD> <SCRIPT language="JavaScript"> function setCookie(){

 var thename= "your name";
 var the_text="name="+thename+"&";
 var toexpire= new Date("March 31, 2010");
 var expdate="expires="+toexpire.toGMTString();
 the_text+=expdate;

 var newtext=escape(the_text);
 document.cookie=newtext;
 var mycookie=document.cookie;
 var fixed_cookie= unescape(mycookie);
 var thepairs= fixed_cookie.split("&");
 var pair1= thepairs[0];
 var pair2= thepairs[1];
 var namevalue= pair1.split("=");
 window.alert("Welcome, "+namevalue[1]+"!");

} setCookie(); </SCRIPT> </HEAD> <BODY> text </BODY> </HTML>


 </source>
   
  


Set the cookie expire date

   <source lang="html4strict">

<html> <head> <title>Hello Cookie</title> <script type = "text/javascript"> var cookName = "cookie1"; var cookVal = "testvalue"; var date = new Date(); date.setTime(date.getTime()+86400000); var expireDate = date.toGMTString(); var myCookie = cookName + "=" + cookVal + ";expires=" + expireDate; document.cookie = myCookie; </script> </head> <body>

Hello

</body> </html>

 </source>
   
  


Standard cookie functions: extract Cookie Value

   <source lang="html4strict">
 

<html> <script language="JavaScript">

</script> </head> <body> <script> showHits(); </script> </body> </html>



 </source>