Results 1 to 6 of 6

Thread: detect cookie expiration date

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,136
    Thanks
    96
    Thanked 98 Times in 96 Posts

    Default detect cookie expiration date

    anyone happen to know how to detect a cookie's expiration date?

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I don't think so, so I did a quick search on google, see if any of these are of any help:
    http://www.google.com/search?q=detec...ient=firefox-a
    Jeremy | jfein.net

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,136
    Thanks
    96
    Thanked 98 Times in 96 Posts

    Default

    It does not look like it is possible. I don't know for sure though. The best I was able to find was this thread: http://www.webmasterworld.com/php/3369153.htm

  4. #4
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    No, there is no way to read the cookie expiry date using a browser's javascript once it has been created UNLESS you add a separate entry into the cookie as a value-data pair as you would do for any other saved data - the expiry date is not given back by the browser because it is considered a security issue. You must be executing code coming from the creator domain to read cookie data anyway, so the cookie must belong by you therefore you already have the full control to add whatever data you need to retrieve later as you see fit. This technique is commonly used by yahoo's cookies, etc. to make the date available, and is often called 'age'.

    Java (not javascript) does have a class constructor and method getMaxAge(), but the feedback comes from the browser, so it will return -1 for not set, meaning good only for the session life, and returns 0 for set to a future date (If I remember correctly).

  5. The Following User Says Thank You to Strangeplant For This Useful Post:

    james438 (11-01-2008)

  6. #5
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,136
    Thanks
    96
    Thanked 98 Times in 96 Posts

    Default

    Thanks for the explanation . I can view the expiration of the cookies if I use Opera, so that's one option. I have not tried the other browsers yet.
    Last edited by james438; 10-31-2008 at 08:18 AM. Reason: typo

  7. #6
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Just add the expiry date of the cookie when creating it.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  8. The Following User Says Thank You to tech_support For This Useful Post:

    james438 (11-01-2008)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •