TAXES

TECHNOLOGY

SERVICES

CRYSTAL COMPUTER CONCEPTS

DELAWARE'S   ·      MIDDLETOWN  ·     ODESSA  ·    TOWNSEND AREA

JavaScript can bake a cookie just as a server-side scripting language.

This page will illustrate how a cookie is formed using JavaScript.

Some ingredients: the small bits of information--

Cookie_Name=Value
cookie_name the value Expiration Date
an attribute specifed by the scriptname choosen by userBrowser's Delete Date

A function setCookie() bakes the JavaScript Cookie--- setCookie(cookie_name, user_value, expiration_days)
Let's abbreviate the 3 ingredients as:cookie_n, user_v, and exp_days with the values mycookie, Jo4s98, 2.

Now let us use JavaScript to set and fetch the Cookie:

<script type="text/javascript">
<!-- Hide from non-JavaScript Browsers
	function setCookie(cookie_n,user_v,exp_days)
	{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exp_days);
	var values=escape(user_v) + " and expires " + exdate;
	document.cookie=cookie_n + "=" + values;
	document.write(document.cookie);
}

//Stop hiding from older browsers -->
</script>

The setCookie function is called and written with the document write method.


DELAWARE'S MIDDLETOWN ODESSA AND TOWNSEND AREA