User:LinguistAtLarge/cookie.js

function set_cookie(name, val, exp) {	document.cookie = name + '=' + escape(val) + '; path=/' + (typeof(exp) != 'undefined' ? '; expires=' + exp.toGMTString : ''); } function get_cookie(name) {	name = name + "="; len = document.cookie.length; start_pos = 0; while (start_pos < len) {		val_start_pos = start_pos + name.length; if (document.cookie.substring(start_pos, val_start_pos) == name) {			var end_pos = document.cookie.indexOf(";", val_start_pos); if (end_pos == -1) {				end_pos = len; }			var val = unescape(document.cookie.substring(val_start_pos, end_pos)); return val; }		start_pos = document.cookie.indexOf(' ', start_pos) + 1; if (start_pos == 0) {			break; }	}	return null; }