Improve company productivity with a Business Account.Sign Up

x
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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