The cookie module provides methods for interacting with browser cookies.
var cookie = require('bv-ui-core/lib/cookie');
cookie.create('RememberMe', '1', 365);
console.log(cookie.read('RememberMe')); // '1'
cookie.remove('RememberMe');
read(name)
: Read the cookie with the given name.create(name, value, [days, domain, secure])
: Write a cookie with the given name and value. Set the expiration in days using thedays
argument; set the domain using thedomain
argument; indicate that the cookie is secure by passingtrue
as thesecure
argument. Note that if one optional argument is provided, all previous arguments must be provided as well.remove(name)
: Delete the cookie with the given name.
- Call
cookieConsent.initConsent
before callingcookie.create
. - Cookies will get created only if the consent for that cookie is true.
- Each cookie will automatically subscribe to
enable
anddisable
consent events for that cookie. - Cookie will get set when consent is
true
. - Cookie will get removed when consent is
false
.