See also: killCookie, readCookie

Function used to set a cookie.

Syntax

JSV_setCookie(name, value [, hours, path, domain, secure])

Prototype

n/a

Returns

The JSV_setCookie function does not return a value.

Parameters

The JSV_setCookie function uses the following arguments.

Argument Description
name A sequence of characters excluding semicolon, comma and white space. To place restricted characters in the name, use an encoding method such as URL-style %XX encoding.
value A sequence of characters excluding semicolon, comma and white space. To place restricted characters in the value, use an encoding method such as URL-style %XX encoding.
hours Optional. Specifies the number of hours that defines the valid life time of that cookie. Once the expiration date has been reached, the cookie will no longer be stored or given out. If you do not specify dateValue, the cookie expires when the user's session ends.
path Optional. Specifies the URLs in a domain for which the cookie is valid.
domain Optional. Specifies the domain attributes for a valid cookie.
secure Optional. Specifies that the cookie is transmitted only if the communications channel with the host is a secure. Only HTTPS (HTTP over SSL) servers are currently secure. If SECURE is not specified, the cookie is considered sent over any channel. Secure is either true or null.

Remarks

n/a

Dependencies

n/a

Example

The following lines of code

var cookie_Name = "JavaScriptVision";
JSV_setCookie(cookie_Name, 1);
var displayText =
    ( (JSV_readCookie(cookie_Name) == 1) ? 
    "You are visiting the JavaScript Vision Library!" : 
    "You have not visited the JavaScript Vision Library at this time." );
document.write( displayText );

produce