set a cookie to expire in 1 hour in Javascript

Set cookie expiration

var now = new Date();
var time = now.getTime();
time += 3600 * 1000;
now.setTime(time);
document.cookie = ‘username=’ + value +  ‘; expires=’ + now.toUTCString() +  ‘; path=/’;