mircobabini
2/26/2013 - 5:54 PM

Cookie.js

Cookies = {
	set: function (name, value, extime, path) {
		var exdate = new Date(parseInt (extime+'000'));
		var cookievalue = escape (value) +
			((extime == null) ? "" : "; expires=" + exdate.toUTCString()) +
			((path == null) ? "" : "; path=" + path);

		document.cookie = name + "=" + cookievalue;
	},
	get: function (name) {
		var i, x, y, cookies = document.cookie.split (";");
		for (i = 0; i < cookies.length; i++)
		{
			x = cookies[i].substr (0, cookies[i].indexOf ("="));
			y = cookies[i].substr (cookies[i].indexOf("=") + 1);
			x = x.replace (/^\s+|\s+$/g,"");
			if (x == name)
				return unescape (y);
		}

		return undefined;
	},
	isset: function (name) {
		var cookie = this.get (name);
		return (cookie != null && cookie != "");
	}
}