Login   Register  
Icontem

File: cookie.html

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Marko Schulz  >  Cookie  >  cookie.html  >  Download  
File: cookie.html
Role: Example script
Content type: text/plain
Description: example page
Class: Cookie
Set and get the values of cookies
Author: By
Last change:
Date: 2011-11-02 01:34
Size: 1,468 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_EN" lang="en_EN">
<head>
	<title>JS Cookie</title>
	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
	<script type="text/javascript" src="./cookie.js"></script>
<script type="text/javascript">
//<![CDATA[

var session;

/*
 * The onload function to set session properties.
 *
 * @return void
 */
window.onload = function() {

// create the session object
session = new Cookie();

// set class properties
session.setVar('path', '/');
session.setVar('expire', 3600); // seconds

};

//]]>
</script>
</head>

<body>

<h1>Cookie Example</h1>

<p><a href="javascript:void(0);" onclick="javascript:session.setCookie('bubu','I am the -bubu- Cookie');">Set the Cookie</a></p>
<p><a href="javascript:void(0);" onclick="javascript:alert(session.getCookie('bubu'));">Get the Cookie</a></p>
<p><a href="javascript:void(0);" onclick="javascript:alert(session.isset('bubu')?'Cookie -bubu- is available!':'Cookie -bubu- does not exist!');">Check the Cookie</a></p>
<p><a href="javascript:void(0);" onclick="javascript:session.unset('bubu');">Delete the Cookie</a></p>
<p><a href="javascript:void(0);" onclick="javascript:alert('The Cookie has an life time of '+session.getVar('expire')+' seconds. The path is set to '+session.getVar('path')+'.');">Info about the Cookie</a></p>

</body>
</html>