Skip navigation
Currently Being Moderated

cfcookie question

Jul 26, 2012 10:11 AM

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,

 

^_^

 
Replies
  • Currently Being Moderated
    Jul 26, 2012 11:01 AM   in reply to WolfShade

    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>

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 11:25 AM   in reply to WolfShade

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 12:02 PM   in reply to WolfShade

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points