<cfcookie name="CFID" value="#session.cfid#" domain=".demo.labs.dev">
Run Code Online (Sandbox Code Playgroud)
收益率:
Set-Cookie:CFID = 4215; 域= .labs.dev; Expires = Sat,04-Jul-2043 01:43:49 GMT; 路径= /; 仅Http
但如果我<cfheader>直接使用:
<cfheader name="Set-Cookie"
value="CFID=4212; Domain=.demo.labs.dev; Expires=Sat, 04-Jul-2043 01:37:03 GMT; Path=/; HttpOnly">
Run Code Online (Sandbox Code Playgroud)
收益率:
Set-Cookie:CFID = 4212; 域= .demo.labs.dev; Expires = Sat,04-Jul-2043 01:37:03 GMT; 路径= /; 仅Http
这就是我想要的.
为什么<cfcookie>这样做?目前的解决方法是使用<cfheader>.
是否可以检查 cookie 何时到期?我尝试了以下方法:
首先我设置了三个cookie:
<cfcookie name="test1" value="" expires="10" />
<cfcookie name="test2" value="" expires="never" />
<cfcookie name="test3" value="" expires="now" />
Run Code Online (Sandbox Code Playgroud)
然后在另一个页面上我检查 cookie 数据:
<cfset cookies = getPageContext().getRequest().getCookies()>
<Cfoutput>
<cfloop index="c" array="#cookies#">#c.getName()#:#c.getMaxAge()#<br>
</cfloop>
</Cfoutput>
Run Code Online (Sandbox Code Playgroud)
但是MaxAge返回-1所有 cookie 而不是实际到期日期。我怎样才能得到实际的到期日期?