Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems With Cookies

Status
Not open for further replies.

dbrooks74

Programmer
Nov 13, 2001
105
US
For whatever reason I cannot get my cookies to be persistent. Can someone tell me if it is in my code or something else?

<%@ Language=VBScript%>
<%Response.Buffer=true%>
<HTML>
<HEAD>
<TITLE>Test Paco</TITLE>
</HEAD>
<BODY>
<%
If Request.Cookies(&quot;paco&quot;) = &quot;Cake&quot; Then
greet = &quot;Welcome Back To Pacos&quot;
Else
greet = &quot;Welcome To Pacos!&quot;
Response.Cookies(&quot;paco&quot;)=&quot;Cake&quot;
Response.Cookies(&quot;paco&quot;).Expires = (date()+7)
End If
Response.Write greet
%>
</BODY>
</HTML>


Any ideas you have are greatly appreciated.

Thanks.
 
Hi,

writing cookies needs to be done before the headers, put your asp code above your opening html tag and test.

Digga

Sharing Knowledge Saves Valuable Time!
 
make that before the html, lol

Digga

Sharing Knowledge Saves Valuable Time!
 
Unfortunetly it still doesn't work. Any other ideas?
 
This is the way I set cookies.

Response.Cookies(&quot;MyCookie&quot;)(&quot;Paco&quot;) = &quot;CaKe&quot;
Response.Cookies(&quot;Mycookie&quot;)(&quot;Paco1&quot;)= &quot;Wine&quot;
Response.Cookies(&quot;Mycookie&quot;).Expires = Date + 7

I reference this way.

if Request.Cookies(&quot;Mycookie&quot;).HasKeys Then
test = request.cookie(&quot;MyCookie&quot;)(&quot;Paco&quot;)
test1 = request.cookie(&quot;MyCookie&quot;)(&quot;Paco1&quot;)
else
response.write &quot;No Cookies&quot;
end if
 
I just implemented your change and it works the same as the old one. The cookie only last as long as the window is open. After the window is closed then reloaded it says &quot;No Cookies&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top