Solved

Set "Expires" attribute for a cookie

Posted on 2002-07-03
3
285 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 50 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

Technology Partners: 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 recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

705 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