Im trying to get a cookie written through javascript with an expire time of 30 minutes. I’ve followed many threads on stack and other websites, and I have a code I believe should be working, but the cookie isn’t writing.
<script>
var date = new Date();
date.setTime(date.getTime()+(30*60*1000));
var expires = date.toGMTString();
var offset= -d.getTimezoneOffset()/60;
document.cookie = 'timezone='+offset+';expires='+expires+';path=/';
</script>
Any idea why this isnt working? the oddest thing, i had the cookie writing earlier, but i couldn’t get the expire time to work properly, and now i can’t get it to write at all! Im almost certain I changed my code back to what was originally working (without the expire time) but now i cant get it to go at all.
Any ideas?
You seem to be using some
dvariable here that is not defined and you are getting a javascript error (did you look in your javascript console by the way?):You probably meant:
as your variable is called
date.