no, it still drops the cookie the next time you open up the browser.
Also, quick question... now that you brought up the expires = ... how do i make it never expire?
Main Topics
Browse All Topicsokay i have a easy question for you guys, but i can't seem to get it working right, its driving me nuts.
Its just a simple cookie. But i am using a form to declare the cookie, i have to figure out how to keep it from reading the form over and over. My problem is... it works fine but when you close the browser and reopen it, the cookie drops for some reason, i think it is trying to pull new info from the form each time. Well here is my code:
page 1 cookiehome.asp
<%
dim homepage
response.cookies("homepage
homepage = request.cookies("homepage"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Test Cookie</title>
</head>
<body>
<%
if homepage="" then
response.cookies("homepage
%>
<a href=cookie2.asp>Add a new home page</a>
<%
else
response.cookies("homepage
'response.write("" & homepage)
%>
<a href="<%response.write("" & homepage)%>" > <%response.write("" & homepage)%> </a><br>
<a href=cookie2.asp>Change Home Page</a>
<%
end if
%>
</body>
</html>
page 2 cookie2.asp
<%
response.buffer=true
dim homepage
response.cookies("homepage
homepage=request.cookies("
%>
<html>
<body>
<%
if homepage="" then
response.cookies("homepage
response.write("Welcome! Please enter in a website address.")
else
response.cookies("homepage
response.write("This is your current home page: " & homepage)
end if
%>
<form method="POST" action="cookiehome.asp">
<p><input type="text" value="http://" name="frm_homepage" size="20"> e.g. MSN please enter in www.msn.com<br>
<input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
you can't really make it *never* expire...all you can do is set the expiration date to some very far off date. But realistically, you don't have a whole lot of control over users and their cookies, as they can have cookies disabled, they can clean out all their cookies on a semi regular basis, etc.
On that note, please make sure that cookies are enabled on your client browser where you're testing this.
Regards,
peh803
okay well thats fine, i can just keep the date to a year from now. The browsers are set to accept cookies... for some reason, this form keeps dropping the cookie... i made another quick one, and made it set to 1 and everytime it loaded it +1 and that worked just fine, i am not sure what is wrong with this code though?
if you dont want to over write your cookie then do somthing like this
dim homepage
homepage = request.cookies("homepage"
If homepage <> "" Then
Else
response.cookies("homepage
End If
and from page two remove response.cookies("homepage
Ok try giving the cookie a name???
<%
If Request.Cookies("myCookie"
cDate = DateSerial((intThisYear+2)
Response.Cookies("myCookie
Response.Cookies("myCookie
Else
End If
%>
<% =Request.Cookies("myCookie
okay... well i changed my code all around to make it even easier, but it still doesn't save the cookie. If i clear my cookies and only open these two pages, there will be a cookie file... but once the browse is closed, the cookie file goes back to a default file and deletes my stored text. well here is my new code
Page1 cookie22.asp
<html>
<body>
Please Enter In Home Page Link
<form method="POST" action="cookie223.asp">
<p><input type="text" value="http://" name="frm_homepage" size="20"> e.g. MSN please enter in www.msn.com<br>
<input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>
Page2 cookie223.asp
<%
response.buffer=true
Response.Cookies("homepage
Response.Cookies("homepage
homepagelink= Request.Cookies("homepage"
dim homepagelink
%>
<HTML>
<head></head>
<body>
<%
if homepagelink="" then
%>
<a href=cookie22.asp>Add a new home page</a>
<%
else
%>
<a href="<%response.write("" & homepagelink)%>" > <%response.write("" & homepagelink)%> </a><br>
<a href=cookie22.asp>Change Home Page</a>
<%
end if
%>
</body>
</HTML>
Well... thanks for your guys help anyway, but i got it... i am not sure why its happening like this, but it kept dropping the cookie because the cookie was being overwritten everytime a new broswer was opened, so I made three pages totally and now it works. Here they are if you care
How do I close this ticket with a no solution?
Page 1 test.asp
<%
response.buffer=true
dim homepage
homepage=request.cookies("
%>
<html>
<body>
<%
if homepage="" then
%>
<a href=../homepagelink/>Add a new home page</a>
<%
else
%>
<a href="<%response.write("" & homepage)%>" > <%response.write("" & homepage)%></a>
<a href="../homepagelink/"><i
<%
end if
%>
</body>
</html>
page 2 index.asp
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="3%">
</td>
<td width="97%">
<p align="left"><font face="Tahoma" color="#000080">Please Enter In Home Page Link</font></p>
<form method="POST" action="thankyou.asp">
<p align="left"><input type="text" value="http://" name="frm_homepage" size="20"> e.g. MSN please enter in www.msn.com<br>
<input type="submit" value="Submit" name="B1"></p>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
page 3 thankyou.asp
<%
response.buffer=true
Response.Cookies("homepage
Response.Cookies("homepage
homepagelink= Request.Cookies("homepage"
dim homepagelink
%>
<html>
<head></head>
<body>
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="788">
<tr>
<td width="100%" valign="top">
<p align="center">
<p align="center">
<font face="Tahoma"><font color="#5A7A9E"><font size="4">
<%
response.write("Your New Home Page Link: " & homepagelink)
%></font> </font>
<br><br><a href=../homepagelink/>Chan
<br><a href=../homepagelink/test.
</font>
</td>
</tr>
</table>
You'll have to post a request in the community support forum to have the thread close and points refunded.
http://www.experts-exchang
Thanks again,
peh803
Business Accounts
Answer for Membership
by: peh803Posted on 2004-11-16 at 07:23:58ID: 12594530
instead of this:
").Expires =date+365
").Expires =dateAdd(" d", 365, date())
INDEX/date add.html
response.cookies("homepage
Try this:
response.cookies("homepage
More on dateAdd() function here:
http://mikecaldwell.com/VB
Hope this helps!
peh803