Invisible cookies with Javascript for IE 6

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wolfgang Adamec

    Invisible cookies with Javascript for IE 6

    Hello everybody!
    I had no experience with cookies up to today.
    I read about the properties of cookies. Then I started to write
    a few lines of Javascript into my html-page:

    function SetMyValue(name , val)
    {
    document.cookie = name+"="+val;
    }

    and

    SetMyValue('fir stname','michae l');

    I did not set the properties "expires" and "domain".

    When I put the page to my server, called it with the IE 6 and looked
    into the IE for my cookie, it was not there. But when I made a cgi program
    that showed HTTP_COOKIE, I saw, that the IE was sending it. So I had
    an invisible cookie with my IE. Only when closed the IE and opened it again,
    it was lost.
    Strange thing!
    Wolfgang Adamec

    ---

  • Robert

    #2
    Re: Invisible cookies with Javascript for IE 6

    In article <c46cf94b.04051 41028.1cd4a9bb@ posting.google. com>,
    w.adamec@gmx.at (Wolfgang Adamec) wrote:
    [color=blue]
    > Hello everybody!
    > I had no experience with cookies up to today.
    > I read about the properties of cookies. Then I started to write
    > a few lines of Javascript into my html-page:
    >
    > function SetMyValue(name , val)
    > {
    > document.cookie = name+"="+val;
    > }
    >[/color]

    I suggest using an existing set of cookie routines. The document.cookie
    can contain existing cookies and you need to preserve them. ( Don't know
    why such routines aren't shipped with the browsers. )


    ~kaeli~ has developed some cookie code. You may view it in this article:


    ..1af96c2a4f8ab c94989dcc%40nnt p.lucent.com

    Also, ~kaeli~ reports that:
    There's some even better code that sets more cookie properties like
    domain, secure, path, etc here.




    Robert

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Invisible cookies with Javascript for IE 6

      Robert <rccharles@my-deja.com> writes:
      [color=blue][color=green]
      >> document.cookie = name+"="+val;[/color][/color]
      [color=blue]
      > I suggest using an existing set of cookie routines. The document.cookie
      > can contain existing cookies and you need to preserve them.[/color]

      This code will preserve existing cookies. The cookie property is "magical"
      in the sense that it doesn't act like a normal object property. Assigning
      such a string, preferably with host/path/expiration information as well,
      will only add one cookie to the set that exists. Reading it back will
      generate a string containing all cookies, with no expiration information.

      Try this code:
      ---
      document.cookie = "hello=worl d";
      document.cookie = "world=now" ;
      alert(document. cookie);
      ---

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • Robert

        #4
        Re: Invisible cookies with Javascript for IE 6

        Lasse Reichstein Nielsen <lrn@hotpop.com > wrote in message news:<ad0arpid. fsf@hotpop.com> ...[color=blue]
        > Robert <rccharles@my-deja.com> writes:
        >[color=green][color=darkred]
        > >> document.cookie = name+"="+val;[/color][/color]
        >[color=green]
        > > I suggest using an existing set of cookie routines. The document.cookie
        > > can contain existing cookies and you need to preserve them.[/color]
        >
        > This code will preserve existing cookies.[/color]

        How true. Indeed the cookie code I use uses a regular assignment.

        Robert

        Comment

        • Robert

          #5
          Re: Invisible cookies with Javascript for IE 6

          ..[color=blue]
          >
          > When I put the page to my server, called it with the IE 6 and looked
          > into the IE for my cookie, it was not there. But when I made a cgi program
          > that showed HTTP_COOKIE, I saw, that the IE was sending it. So I had
          > an invisible cookie with my IE. Only when closed the IE and opened it again,
          > it was lost.[/color]

          How do you want the cookie to work?

          Without giving the date, the cookie expires when the session goes
          away.

          I have had a bit of trouble with cookies with IE when I didn't specify
          the date. The cookie would disappear on me. I found it necessary to
          provide a date

          Robert

          Comment

          Working...