title: How can I set a cookie with expire time?
body: <p>I am setting a cookie with JavaScript and it is working fine but it is not taking the expire time I am giving. It keeps on taking session value regardless of what I give, below is the code which I took from <a href="https://stackoverflow.com/questions/3794989/how-to-set-a-cookie-to-expire-in-1-hour-in-javascript">here</a></p>
  <pre><code>var now = new Date();
  var time = now.getTime();
  var expireTime = time + 1000*60;
  now.setTime(expireTime);
  var tempExp = 'Wed, 31 Oct 2012 08:50:17 GMT';
  document.cookie = aaa+'='+sStr+';expires='+now.toGMTString()+';path=/';
  </code></pre>
  <p>I tried giving hard-coded value but still it is showing expire as session in chrome dev tool</p>
  <pre><code>var tempExp = 'Wed, 31 Oct 2012 08:50:17 GMT';
  document.cookie = aaa+'='+sStr+';expires='+tempExp+';path=/';
  </code></pre>
  <p>Any idea what I am doing wrong?</p>