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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookies and Expires values ?

Status
Not open for further replies.

PeterMac

Programmer
Mar 9, 2001
51
CA
I have code that depends on the expiry date of a cookie. I can set the expiry date of the cookie, but I can't figure out how to get the value of the Expires property.
I tried this...
<%= Request.Cookies(&quot;Voted&quot;).expires %>
but it calved on me...
I know that if the cookie does not exist that I will get an empty string, but I want to do something with the date value. Is there any way to pick this value up ?

Peter
 
Here's an idea.

When you write cookie to the user's computer, add one more key to it to
Let's assume you're your (&quot;Voted&quot;) cookie like that:

<%

response.cookies(&quot;Voted&quot;)(&quot;Name&quot;) = something
response.cookies(&quot;Voted&quot;)(&quot;Birthday&quot;)= something
response.cookies(&quot;Voted&quot;).expires = date + 365

%>


Just add one more key , (&quot;Expires&quot;), to cookie to hold cookie's expiration date:


<%

response.cookies(&quot;Voted&quot;)(&quot;Name&quot;) = something
response.cookies(&quot;Voted&quot;)(&quot;Birthday&quot;)= something

response.cookies(&quot;Voted&quot;)(&quot;Expires&quot;)= date + 365
response.cookies(&quot;Voted&quot;).expires = date + 365

%>


Now you'll be able to get this value, which is the same as cookie's expiry date:

<%response.write request.cookies(&quot;Voted&quot;)(&quot;Expires&quot;)%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top