• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

Set "Expires" attribute for a cookie

i need to set a cookie that will last "forever" .. how do i do that ??
(in JScript)

10x
0
dragosh
Asked:
dragosh
1 Solution
 
AlfaNoMoreCommented:
var d = new Date();
var nextMillenium = d.setFullYear(d.getYear() + 1000);
Response.Cookies('myCookie').Expires = nextMillenium;

OK, it doesn't last "Forever", but who'd going to know?? :-)
0
 
ManuelMSPCommented:
Here you are:

if (getCookie(NameOfCookie)) {
  document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

By the time it's 1970 again... If there not manually deleted !
0
 
dragoshAuthor Commented:
AlfaNoMore:

i think adding 1 year it's enough :))

10x
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now