Blog Post
Using cookies in JavaScript

Cookies are small items of data, each consisting of a name and value,
stored on behalf of a website by visitors’ web browsers. In JavaScript, cookies can be accessed through the document.Cookies.js is a JavaScript object that allows cookies to be created, retrieved, and deleted through a simple and intuitive interface.
Download Cookies.js files below and use for cookies.

how to SetCookie:

Cookie.Set('color','blue');

For create cookies set 2 parameter cookie name and parameter.
The value of the property can be either a date on which the cookie will expire or a number of seconds after which the cookie should expire:

Cookies.set('theme', 'green', {expiry : 3600});

if you want cookies to access only one domain then
Cookies.set(‘name’, ‘Shilpa’, {expiry : new Date(2030, 0, 1)});

Retrieving Cookies

if you retrive, cookies value then,

var theme = Cookies.get('color');

Deleting cookies

if you delete cookies value then,

Cookies.clear('color');

For detailed please see http://code.iamkate.com/javascript/using-cookies/

Tags In
February 15, 2019

Leave an reply

Your email address will not be published. Required fields are marked *