Cookies under 1 day does not work !

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fabrice Labrousse

    #1

    Cookies under 1 day does not work !

    Hello,

    after many deep searches on javascript and cookies, i still cannot have an
    answer for a incredible cookie problem !
    here it is, i hope you'll be able to answer me :

    This is my function that put on a disk a cookie that has a 5 minutes
    duration


    function pose_5minutesco okie()
    {
    var expdate=new Date();
    expdate.setTime (expdate.getTim e() + (5 * 60 * 1000));
    alert ("expires=" + expdate);
    document.cookie = 'test=1; expires=' + expdate.toGMTSt ring() + '; path=/;
    domain=eg_domai n';
    window.history. go(0);
    }

    the alert says that the expiration date is well calculated
    the cookie sets on the drive

    BUT

    The cookie never expires !!!!!!!!

    Another interesting expérience is that if i change the time to less than 500
    (ms that's right !) instead of 5 minutes (in the example), the cookie does
    not appear on the disk. I think this should mean that its living time is too
    short to be written. I admit but if i run this cookie to expire in 1000 ms,
    it appears ont the disk but it never expire !

    Any idée ? Did anybody ran a 5 minutes cookie ?

    Fabrice



  • Erwin Moller

    #2
    Re: Cookies under 1 day does not work !

    Fabrice Labrousse wrote:
    [color=blue]
    > Hello,
    >
    > after many deep searches on javascript and cookies, i still cannot have an
    > answer for a incredible cookie problem !
    > here it is, i hope you'll be able to answer me :
    >
    > This is my function that put on a disk a cookie that has a 5 minutes
    > duration
    >
    >
    > function pose_5minutesco okie()
    > {
    > var expdate=new Date();
    > expdate.setTime (expdate.getTim e() + (5 * 60 * 1000));
    > alert ("expires=" + expdate);
    > document.cookie = 'test=1; expires=' + expdate.toGMTSt ring() + ';
    > path=/;
    > domain=eg_domai n';
    > window.history. go(0);
    > }
    >
    > the alert says that the expiration date is well calculated
    > the cookie sets on the drive
    >
    > BUT
    >
    > The cookie never expires !!!!!!!!
    >
    > Another interesting exp�ience is that if i change the time to less than
    > 500 (ms that's right !) instead of 5 minutes (in the example), the cookie
    > does not appear on the disk. I think this should mean that its living time
    > is too short to be written. I admit but if i run this cookie to expire in
    > 1000 ms, it appears ont the disk but it never expire !
    >
    > Any id� ? Did anybody ran a 5 minutes cookie ?
    >
    > Fabrice[/color]

    Hi Fabrice,

    I am not sure, but maybe it is this:

    It depends on what you mean by 'never expires'?
    If you mean that the coockiefile exists on disk. --> okay. You cannot expect
    your browser to scan every possible cookie from every possible site every
    millisecond to check if it should delete them, can you?

    If you mean that you try to read the value of test 10 minutes later the
    normal way (that is not looking at the file, but reading it using
    javascript), and it still shows up. --> your browser is broken, or you made
    some mistake in the setting/getting of the cookie.
    Maybe you are setting the cookie every time again (with a timestamp of +5
    minutes from now)
    Hard to tell without the complete code/logic.

    I expect a browser to update the coockie (and delete it) only when needed.

    Hope this helps,
    regards,
    Erwin Moller

    Comment

    • Fabrice Labrousse

      #3
      Re: Cookies under 1 day does not work !

      Hello Erwin,

      You were right, cookies are working fine. I was sure the cookie had to
      disapear from the disk but it doesn't and anyway the cookie duration was ok.
      Thank you very much for your help, i was stupidily stuck but you gave me the
      idea i did not test.

      Regards
      Fabrice
      "Erwin Moller"
      <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> a écrit dans
      le message de news: 4028a4c5$0$190$ e4fe514c@news.x s4all.nl...[color=blue]
      > Fabrice Labrousse wrote:
      >[color=green]
      > > Hello,
      > >
      > > after many deep searches on javascript and cookies, i still cannot have[/color][/color]
      an[color=blue][color=green]
      > > answer for a incredible cookie problem !
      > > here it is, i hope you'll be able to answer me :
      > >
      > > This is my function that put on a disk a cookie that has a 5 minutes
      > > duration
      > >
      > >
      > > function pose_5minutesco okie()
      > > {
      > > var expdate=new Date();
      > > expdate.setTime (expdate.getTim e() + (5 * 60 * 1000));
      > > alert ("expires=" + expdate);
      > > document.cookie = 'test=1; expires=' + expdate.toGMTSt ring() + ';
      > > path=/;
      > > domain=eg_domai n';
      > > window.history. go(0);
      > > }
      > >
      > > the alert says that the expiration date is well calculated
      > > the cookie sets on the drive
      > >
      > > BUT
      > >
      > > The cookie never expires !!!!!!!!
      > >
      > > Another interesting exp?ience is that if i change the time to less than
      > > 500 (ms that's right !) instead of 5 minutes (in the example), the[/color][/color]
      cookie[color=blue][color=green]
      > > does not appear on the disk. I think this should mean that its living[/color][/color]
      time[color=blue][color=green]
      > > is too short to be written. I admit but if i run this cookie to expire[/color][/color]
      in[color=blue][color=green]
      > > 1000 ms, it appears ont the disk but it never expire !
      > >
      > > Any id? ? Did anybody ran a 5 minutes cookie ?
      > >
      > > Fabrice[/color]
      >
      > Hi Fabrice,
      >
      > I am not sure, but maybe it is this:
      >
      > It depends on what you mean by 'never expires'?
      > If you mean that the coockiefile exists on disk. --> okay. You cannot[/color]
      expect[color=blue]
      > your browser to scan every possible cookie from every possible site every
      > millisecond to check if it should delete them, can you?
      >
      > If you mean that you try to read the value of test 10 minutes later the
      > normal way (that is not looking at the file, but reading it using
      > javascript), and it still shows up. --> your browser is broken, or you[/color]
      made[color=blue]
      > some mistake in the setting/getting of the cookie.
      > Maybe you are setting the cookie every time again (with a timestamp of +5
      > minutes from now)
      > Hard to tell without the complete code/logic.
      >
      > I expect a browser to update the coockie (and delete it) only when needed.
      >
      > Hope this helps,
      > regards,
      > Erwin Moller[/color]


      Comment

      Working...