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:
-
name
[string](name of the cookie) -
value
[mixed](value to store) -
expires
[string](date in UTC format) -
path
[string](path to read the cookie)
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

