Constructor Cookie
Cookie constructor function.
-
Syntax
Cookie new Cookie(String name , [ Number age , [ String path , [ String domain , [ Boolean secure ]]]])
Creates and returns a new Cookie object. -
Parameters
String name- A name for the cookie so you can retrieve it later.
Number age(Optional)- The lifetime of the cookie in seconds. Default value is 0 meaning the cookie expires when the browser is closed.
String path(Optional)- The path of the domain in which this cookie is available. Default value is the path from where the script file originates.
String domain(Optional)- The domain in which the cookie is available. Default value is the domain fro where the script file originates.
Boolean secure(Optional)- If true the cookie is only transmitted by HTTPS; otherwise it can also be transmitted by HTTP. Default value is false.
- Return value A new Cookie object
-
Examples
- To simply create a cookie which can later be retrieved by the name of 'myCookie' with a lifetime of 1 week
// 1 week is 7 days * 24 hours * 60 minutes * 60 seconds = 604800 seconds new Cookie('myCookie',604800);- To create a new cookie which can be used by any file from the subdomain www.jslab.dk and the path /demo/
new Cookie('myCookie',604800,'/demo/');- To create a cookie which can be accessed by all files in all paths of all subdomains of the domain jslab.dk
new Cookie('myCookie',604800,'/','jslab.dk');
- Resources See the Wikipedia entry on cookies at http://en.wikipedia.org/wiki/HTTP_cookie.
-
Download
Source
Unless otherwise noted all code in the JSLab Standard Library is licensed as GPLv3. See http://www.gnu.org/licenses/gpl.html for the entire license.
