diet-cookies

HTTP Cookie Manager for diet.js.

npm install diet-cookies
4 downloads in the last week
7 downloads in the last month

Diet-Cookies

HTTP Cookie Manager for diet

Install

If you have diet it's already installed.

    npm install diet-cookies

Example usage

app.get.simple('/', function(request, response){
    // GET cookie
    console.log(request.cookies.id);

    // SET cookie
    response.cookies.set('name', 'john doe', { httpOnly: true }); // options are optional

    // DELETE cookie
    response.cookies.delete('location');

    // END response
    response.end('diet is healthy!');
});

How it works?

  • You canGET cookies fromrequest.cookies[id]
  • You can SET or UPDATE cookies with response.cookies.set(id, value, options)
  • You can DELETE cookies withresponse.cookies.delete(id)

Options for response.cookies.set

{
    "httpOnly": false,     // true or false
    "secure": false,     // true or false
    "domain": null,     // null or domain string
    "path": null,          // null or path string
}

Dependencies

  • dietjs
npm loves you