Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q889 What happens to cookie expiry dates after 31st December 1999?

You are here: irt.org | FAQ | JavaScript | Cookie | Q889 [ previous next ]

Take a look at http://www.netscape.com/newsref/std/cookie_spec.html which specifies that the expiry date should use 4 digit dates. If you are using two digit dates then you'll hit a y2k problem. To ensure that you are using a full four digit date use the robust y2k() JavaScript function when extracting the year from a date object:

<script language="JavaScript"><!--
function y2k(number) { return (number < 1000) ? number + 1900 : number; }

var now = new Date();

year = y2k(now.getYear());
//--></script>

©2018 Martin Webb