Zebra_Cookie examples
Installation
Load the latest version of jQuery either from a local source, or from a CDN
<script type="text/javascript" src="path/to/jQuery.js"></script>
Load the Zebra_Cookie plugin
<script type="text/javascript" src="path/to/zebra_cookie.js"></script>
Usage
// inside the DOM-ready function
// a "cookie" object will be available in jQuery’s namespace
// the object exposes 3 methods that you can use to write, read and delete cookies
$(document).ready(function() {
// create a session cookie (expires when the browser closes)
$.cookie.write('cookie_name', 'cookie_value');
// create a cookie that expires in 1 day
$.cookie.write('cookie_name', 'cookie_value', 24 * 60 * 60);
// read a cookie’s value
// following the examples above, this should return "cookie_value"
$.cookie.read('cookie_name');
// the "read" method returns null if the cookie doesn’t exist
$.cookie.read('non_existing_cookie_name');
// delete the cookie
$.cookie.destroy('cookie_name');
});