src/cookie.js

Cookies

TurtleIO.prototype.cookie = {

Method expire

Expires a cookie if it exists

Parameters:

  • res must be an Object.
    (HTTP(S) response Object)

  • name must be a String.
    (Name of the cookie to expire)

  • domain must be a String.
    ([Optional] Domain to set the cookie for)

  • secure must be a Boolean.
    ([Optional] Make the cookie only accessible via SSL)

  • path must be a String.
    ([Optional] Path the cookie is for)

Returns a String
(Name of the expired cookie)

expire : function ( res, name, domain, secure, path ) { return $.cookie.expire( name, domain, secure, path, res ); },

Method get

Gets a cookie from the request headers

Parameters:

  • req must be an Object.
    (HTTP(S) request Object)

  • name must be a String.
    (Name of the cookie to get)

Returns a Mixed
(Cookie or undefined)

get : function ( req, name ) { return this.list( req )[name]; },

Method list

Gets a list cookies from the request headers

Parameters:

  • req must be an Object.
    (HTTP(S) request Object)

  • name must be a String.
    (Cookie name)

Returns an Object
(Collection of cookies)

list : function ( req ) { return $.cookie.list( req.headers.cookie || "" ); },

Method set

Sets a cookie in the response headers

Parameters:

  • res must be an Object.
    (HTTP(S) response Object)

  • name must be a String.
    (Name of the cookie to create)

  • value must be a String.
    (Value to set)

  • offset must be a String.
    (A positive or negative integer followed by "d", "h", "m" or "s")

  • domain must be a String.
    ([Optional] Domain to set the cookie for)

  • secure must be a Boolean.
    ([Optional] Make the cookie only accessible via SSL)

  • path must be a String.
    ([Optional] Path the cookie is for)

Returns an Undefined
(undefined)

set : function ( res, name, value, offset, domain, secure, path ) { return $.cookie.set( name, value, offset, domain, secure, path, res ); } };