Goto main content

cookies

Manage cookies.

COOKIES

NAME

cookies - Manage cookies.

SYNOPSIS

cookies (); cookies (name:"…",value:"…",expiry:"…",maxage:"…",path:"…",domain:"…",secure:true|false,httponly:true|false,error:true|false);

DESCRIPTION

This function is used to manage cookie.

The first form return an hash array of coookie.

The second form set a cookie.

A cookie contains no more than 255 characters and cannot take up more than 4 K of disk space. It consists of six components:

The name of the cookie
The value of the cookie
The expiry of the cookie (using Greenwich Mean Time)
    Or the Max-Age of cookie as a number of second in the future according to the browser time.
The path the cookie is good for
The domain the cookie is good for
The need for a secure connection to use the cookie

Only the first two components (a name and value) are required for the successful operation of the cookie.

The Expires directive tells the browser when to delete the cookie. Derived from the format used in RFC 1123, the date is specified in the form of “Wdy, DD Mon YYYY HH:MM:SS GMT”,[28] indicating the exact date/time this cookie will expire. As an alternative to setting cookie expiration as an absolute date/time, RFC 6265 allows the use of the Max-Age attribute to set the cookie’s expiration as an interval of seconds in the future, relative to the time the browser received the cookie. An example of Set-Cookie directives from a website after a user logged in:

Set-Cookie: lu=Rg3vHJZnehYLjVg7qi3bZjzg; Expires=Tue, 15 Jan 2013 21:47:38 GMT; Path=/; Domain=.example.com; HttpOnly
Set-Cookie: made_write_conn=1295214458; Path=/; Domain=.example.com
Set-Cookie: reg_fb_gate=deleted; Expires=Thu, 01 Jan 1970 00:00:01 GMT; Path=/; Domain=.example.com; HttpOnly
The first cookie lu is set to expire sometime in 15-Jan-2013; it will be used
by the client browser until that time. The second cookie made_write_conn does
not have an expiration date, making it a session cookie. It will be deleted
after the user closes their browser. The third cookie reg_fb_gate has its
value changed to deleted, with an expiration time in the past. The browser
will delete this cookie right away – note that cookie will only be deleted
when the domain and path attributes in the Set-Cookie field match the values
used when the cookie was created.
 Cookie in firefox without expiration date are not deleted when the browser quit depending
on your configuration.

EXAMPLES

Note: In the followings examples, the _ between the { should be removed to make it work.

{_{
cookies(name:'sednove',value:'pierre',path:"/");
a=datetime(extended:true,op:"+15m",format:"%Sednove2");
cookies(name:'textexp',value:'pierre2',expiry:a,path:"/",domain:".sednove.ca");
cookies(name:'textma',value:'pierre2',maxage:300,path:"/",domain:".sednove.ca");
cookies();
}}

SEE ALSO

{{ include("includes/variables.sn") }}

AUTHOR

Written by Pierre Laplante, <laplante@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2021 extenso Inc. All rights reserved.