p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: AW: checking the existance of a cookie


Message #1 by "Michael Drozdzowicz" <bandit@g...> on Fri, 4 May 2001 10:44:13 +0200
Try this code:

<%
If NOT Request.cookies("schedule") = "" Then
REM OK. Cookie already exist!
Else
REM We need to set a new cookie
response.cookies("schedule") = "Serial #"
   For Each cookie in Response.Cookies
       Response.Cookies(cookie).Expires = now()+365
   Next
End If
%>

Cu
Bandit

-----Ursprüngliche Nachricht-----
Von: Art Herbert [mailto:aherbert@s...]
Gesendet: Freitag, 4. Mai 2001 04:48
An: Code Clinic
Betreff: [proasp_codeclinic] checking the existance of a cookie


I can read and write the cookie but I only want to create the cookie
if it doesn't already exist.
I think the code is this

If Request.QueryString("cookie") = 1 then


It doen't process the above line to be true when the cookie does exist.

More of the code is as follows as a test example

<%
   If Request.QueryString("cookie") = 1 Then
      a = "Old"
   Else
   a = request.cookies("schedule")
   response.cookies("schedule") = "Serial #"
   For Each cookie in Response.Cookies
       Response.Cookies(cookie).Expires = now()+365
   Next
   End If
%>
<p> exist or not <% response.write a %> </p>


  Return to Index