Friday, September 6, 2019

Using cookies in JavaScript

Posted by Web Idea Solution | September 06, 2019 Categories: , ,

 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');
 

Using cookies in JavaScript





0 comments:

Post a Comment

  • Facebook
  • Twitter
  • Linkedin
  • Pinterest
  • Email