function setCookie(key, value, expiry) {
var expires = new Date();
expires.setTime(expires.getTime() + (expiry * 24 * 60 * 60 * 1000));
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}
function getCookie(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
}
function eraseCookie(key) {
var keyValue = getCookie(key);
setCookie(key, keyValue, '-1');
}
$(document).ready(function () {
// You can set the cookies as like
setCookie('test','1','1'); //(key,value,expiry in days)
// You can get the cookies as like
getCookie('test');
// And finally you can erase the cookies like this one
eraseCookie('test');
});