Jquery Cookie Example - Jquery

How to set cookie in jquery?

Snippet Code


  
Rate this page :
  [ 0 votes]

Simple jquery code which allows you to create and read cookies. To run this code you need a cookie.js plugin. Download the plugin through this link : "https://github.com/carhartl/jquery-cookie/blob/master/src/jquery.cookie.js".

<script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script src='cookie.js'></script> <script type='text/javascript'> $.cookie('admin', 'hscripts'); //create session cookie $.cookie('cname', 'cvalue', { expires: 7 });//set cookie with expiring days $.cookie('name'); // to read cookie </script>

Tags


Ask Questions

Ask Question