Get started with jquery-cookie CDN

MIT licensed

JQuery Cookie: Small, easy plugin for handling cookie key-value pairs with jQuery.

Tags:
  • jquery
  • cookie

Stable version

Copied!

How to start using jquery-cookie CDN


// Include the jQuery library before including the cookie plugin
$(document).ready(function() {
  // Include the plugin
  $.cookie.configure({ expires: 7 }); // Set cookie expiration to 7 days

  // Set a cookie
  $.cookie('name', 'John Doe', { path: '/' });

  // Get a cookie
  var name = $.cookie('name');
  console.log('Cookie value:', name);

  // Delete a cookie
  $.removeCookie('name', { path: '/' });

  // Check if a cookie exists
  if ($.cookie('name')) {
    console.log('Cookie exists');
  } else {
    console.log('Cookie does not exist');
  }
});
Copied!
Copied!

All versions