Seems to work for me using jQuery.cookie:
Command: exp = new Date() Output: Thu Aug 09 2012 11:39:21 GMT-0700 (Pacific Daylight Time) Command: exp.setMinutes(exp.getMinutes() + 240) Output: 1344551961739 Command: $.cookie('testCookie', 'test', {path: '/', expires: exp}); Output: "testCookie=test; expires=Thu, 09 Aug 2012 22:39:21 GMT; path=/"
This was done in the Chrome console on the windows.
Note: 22:39 GMT - 15:39 GMT -0700, so this is the expiration of 4 hours.
Edit: I checked your code directly and it does not seem to agree that the cookie expires in less than 4 hours. This does not use jQuery:
exp = new Date(); exp.setMinutes(exp.getMinutes() + 240); document.cookie="testCookie2=test;expires=" + exp.toUTCString() + ";path=/";
source share