?
Solved

Set "Expires" attribute for a cookie

Posted on 2002-07-03
3
Medium Priority
?
288 Views
Last Modified: 2008-03-04
i need to set a cookie that will last "forever" .. how do i do that ??
(in JScript)

10x
0
Comment
Question by:dragosh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
AlfaNoMore earned 200 total points
ID: 7127093
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
 
LVL 2

Expert Comment

by:ManuelMSP
ID: 7127110
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
 
LVL 3

Author Comment

by:dragosh
ID: 7127119
AlfaNoMore:

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

10x
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question