Cookie Plugin

Back to plugins | Download plugin

The Cookie plugin adds 2 methods to easily read and write to cookies.

Read

To get the value of a cookie all you need is the name.

  var value = nano.cookie.read('example');

Write

The nano.cookie.write() method allows you to create a new cookie or modify an existing value. It these arguments in the following order:

  nano.cookie.write('example', 123, nano.time(nano.time()+(24*60*60*1000), 'UTC'), '/');

You can use the nano.time() function to generate the UTC date string. Here we set the expires date to 1 day in the future. The API documentation for nano.time() can be found here