# Trying to shorten a cookie's duration

**URL:** <https://forum.kirupa.com/t/trying-to-shorten-a-cookies-duration/247282>\
**Category:** web dev\
**Created:** [December 20, 2007, 5:18pm UTC](https://forum.kirupa.com/t/trying-to-shorten-a-cookies-duration/247282 "2007-12-20T17:18:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![somnamblst](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@somnamblst](https://forum.kirupa.com/u/somnamblst)\
**Post date:** [December 20, 2007, 5:18pm UTC](https://forum.kirupa.com/t/trying-to-shorten-a-cookies-duration/247282/1 "2007-12-20T17:18:23Z")

</div>

I have a surprisingly simple cap frequnecy cookie for a jQuery slide. I am not using the jQuery cookie plugin which doesn’t have a shorter unit than one day anyways.

I have tried everything my limited JS skills allow but get errors and even worse a disruption of my slide function. My working oneDay cookie slide toggle function

```auto

$(document).ready(function() { 
        initSlideboxes(); 
        function initSlideboxes() 
{
if(!document.cookie.match("slidedToday")){
  var oneDay = new Date();
  oneDay.setDate(oneDay.getDate()+1); 
  document.cookie="slidedToday=true;path=/;expires="+oneDay.toGMTString();
 
  $('#slidebar').slideDown(1000); 
  setTimeout(function() {$('#slidebar').slideUp(10);}, 5000); 
}
        $('#slidebartrigger').click(function(){$ 
('#slidebar').slideToggle(); }); 
 
}; 
}); 

```

A JS programmer suggested I try the following but it didn’t work because I can’t figure out what to put in place of oneDay

```auto
if(!document.cookie.match("slidedToday")){
var currentDate = new Date(); 
var startDate = new Date( currentDate.getYear(), currentDate.getMonth(), currentDate.getDate(), currentDate.getHours()+1, currentDate.getMinutes(), currentDate.getSeconds());
document.cookie="slidedToday=true;path=/;expires="+oneHour.toGMTString();

```

Error is oneHour is undefined, I tried a couple different things like 3600 but I get syntax errors or “,” expected but I don’t have the math head ability to understand what I should try next. The fact that oneDay works makes me wonder what is in [http://code.jquery.com/jquery-latest.pack.js](http://code.jquery.com/jquery-latest.pack.js) that knows what oneDay is.
