cookies - 如何检索 ASP cookie 的 'Expires' 属性值?

标签 cookies vbscript asp-classic

我在 ASP 中创建了一个名为 language 的 cookie,它被设置为字符串 "VBScript"。我已将一个 Expires 属性附加到该属性,其值为 #May 1,2016#。我能够检索 cookie 的值,但在检索过期日期时遇到问题。这是 ASP 代码:

<%
    response.write("Cookie: " & Request.Cookies("language")) ' outputs 'VBScript' 
    response.write("Expiration Date: " & Request.Cookies("language").Expires) ' possible line of error
%>

当我运行此代码时,Cookie 值旁边显示“处理 URL 时发生错误”。请联系系统管理员。如果您是系统管理员,请单击此处了解有关此错误的更多信息。 “此处”部分是 Microsoft 网站的链接。我可能会考虑删除“可能的错误行”,但是在这种情况下有没有办法检索 cookie 的过期日期?

更新:

删除“可能的错误行”只是删除错误消息并仅显示 cookie 的值。

最佳答案

来自: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.

它是一个只写值,无法从中读取。

还有Request.Cookies集合没有名为 Expires 的键。

关于cookies - 如何检索 ASP cookie 的 'Expires' 属性值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36826059/

相关文章:

javascript - 使用 VBScript 的 SOAP POST 请求

asp-classic - 将 FileSystemObject 保存为 UTF

asp-classic - 经典 ASP : Best way to read & write large (5mb+) files using FileSystemObject

javascript - Meteor cookie 和服务器端路由

javascript - 无法使用ssl在php中读取cookie

php - 登录其他网站时自动登录moodle

c# - 如何删除/更新 cookie 容器 c# 中的 cookie?

javascript - 如何从外部 VBScript 在网页中执行 Javascript 函数

css - 在 HTA 中失去焦点时,按钮的虚线边框变为两条实线边框

asp-classic - Asp Classic 包含一次