Cookies are your friend:
// Set a cookie or 2
document.cookie = 'somevar=somevalue';
document.cookie = 'another=123';
function getCookie(name)
{
// Cookies seperated by ; Key->value seperated by =
for(var i = 0; pair = document.cookie.split("; ")[i].split("="); i++)
if(pair[0] == name)
return unescape(pair[1]);
// A cookie with the requested name does not exist
return null;
}
// To get the value
alert(getCookie('somevar'));