This module is deprecated and is no longer maintained. Consider a more standard approach to handling cookies.
Provides a utility for getting or setting the value of cookies. Also contains additional methods for getting and setting parameters of certain FT cookies (which use a variety of different syntaxes)
This module has been verified in Internet Explorer 7+, modern desktop browsers (Chrome, Safari, Firefox, ...) and mobile browsers (Android browser, iOS safari, Chrome mobile).
get(name)
- retrieves the value of cookiename
set(name, value, options)
- sets the value of cookiename
tovalue
. The options object, if specified, can have any of the following propertiesexpires
: Lifetime of the cookie. Value can be a number of days from time of creation or a Date object. default: 730 dayspath
: The path where the cookie is valid default: '/'domain
: The domain where the cookie is valid default: '.ft.com'secure
: Iftrue
the cookie will only be sent over https default: falseraw
: If set totrue
gets/sets a cookie's value without sanitising it withencode/decodeURIComponent()
remove(name)
- unsets the value of a cookiegetParam(name, param)
- gets the value stored in the given parameter within cookiename
(only works for some FT cookies which use a predefined syntax for separating parameters)setParam(name, param, value)
- sets the value stored in the given parameter within cookiename
(only works for the AYSC FT cookie)
The following FT cookies are supported for setting and fetching key-value data from within the cookie
AYSC
FT_U
FT_Remember
FT_User
FTQA
Example:
// Get the value of slot 2 in the AYSC cookie
var val = require('o-cookies').getParam('AYSC', '02');
Copyright (c) 2016 Financial Times Ltd. All rights reserved.
This software is published under the MIT licence.