Hello, everyone.
I know that one can access the cookie scope to get the value of a cookie. Is there anything else that can be retrieved in the cookie scope? Like the expires attribute? Or is there another way to discover the expires value of a cookie?
Thanks,
^_^
Only the value can be retreived form the cookie scope. To get anything else you would need to reach into getPageContext() and get the request so you can fish out the actual cookie objects.
<cfset cookies = getPageContext().getRequest().getHTTPRequest().getCookies() />
<cfloop array="#cookies#" index="cookieIndex">
<cfoutput>
Name: #cookieIndex.getName()#<br />
Value: #cookieIndex.getValue()#<br />
Expires: #cookieIndex.getMaxAge()#<br />
Domain: #cookieIndex.getDomain()#<br />
Path: #cookieIndex.getPath()#
<br /><br />
</cfoutput>
</cfloop>
Actually seconds.
And interestingly, it is seconds after it is set inwhich it is supposed to expire. So really, I don't see anyway for you, from the server, to be able to tell when, specifically, it is supposed to expire. The brower knows when it was set, so it knows when to expire it, but I do not think that that data is sent back to the server.
Jason
No, you can't Because it is not a date/time, it is a timespan. The translation is a periodu of time. For example the valeu might be: 345600. That translates to 4 days, 0 hours, 0 minutes, 0 seconds. It will not translated to August 2nf 2012 at 14:00 CST. So if I set that cookie now and check the MaxAge property it will say 345600, if I check it tomorrow at 6:00 AM it will say 345600. If I check it 3 days from now at 4:00 PM it will say 345600. If I don't know when that cookie was set, I won't know when it will expire.
jason
North America
Europe, Middle East and Africa
Asia Pacific