Reputation: 209
I have created a cookie in ASP called language
which was set to the string "VBScript"
. I've attached an Expires
property to that with the value of #May 1,2016#
. I was able to retrieve the cookie's value, but I am having a problem retrieving the expiration date. Here is the ASP code:
<%
response.write("Cookie: " & Request.Cookies("language")) ' outputs 'VBScript'
response.write("Expiration Date: " & Request.Cookies("language").Expires) ' possible line of error
%>
When I run this code, next to the value of the cookie, it says 'An error occurred while processing the URL. Please contact the system administrator. If you are the system administrator click here to find out more about this error.' The 'here' part was a link to the Microsoft website. I may consider removing the 'possible line of error', but is there a way to retrieve the expiration date of the cookie in this situation?
Removing the 'possible line of error' just removed the error message and just displayed the cookie's value.
Upvotes: 2
Views: 1663
Reputation: 2442
From: Response.Cookies Collection
Expires
Write-only. The date on which the Cookie expires. This date must be set in order for the Cookie to be stored on the client's disk after the session ends. If this attribute is not set to a date beyond the current date, the Cookie expires when the session ends.
It is a write-only value, cannot read from it.
And the Request.Cookies collection has no key called Expires
.
Upvotes: 3