Все, что вам нужно, здесь: http://www.quirksmode.org/js/cookies.html
var name = 'My Cookie',
value = 'foobar';
// Set a cookie without an expires header so it goes away on browser close
document.cookie = name + '=' + value + '; path=/';
// Erase said cookie in 15 minutes if the user left browser open.
setTimeout(function(){
var date = new Date(),
days = -1,
expires = '';
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = '; expires=' + date.toGMTString();
document.cookie = name + '=' + value + expires + '; path=/';
}, 60000 * 15 );