document.cookie on Opera and IE for Mac..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • F@bio

    #1

    document.cookie on Opera and IE for Mac..

    It seems that document.cookie doesn't work both on Internet
    Explorer 5 for Mac (OS 9) and Opera 6 for PC... am I doing
    something wrong? Or does it just not work? I don't get an
    error message, the cookie just simply gets ignored. Do you
    have any suggestions?

    F@bio




  • Michael Winter

    #2
    Re: document.cookie on Opera and IE for Mac..

    F@bio wrote on 03 Dec 2003:
    [color=blue]
    > It seems that document.cookie doesn't work both on Internet
    > Explorer 5 for Mac (OS 9) and Opera 6 for PC... am I doing
    > something wrong? Or does it just not work? I don't get an
    > error message, the cookie just simply gets ignored. Do you
    > have any suggestions?[/color]

    Describe, "ignored". It doesn't appear in the cookie list, or
    retrieving a value, in the same session, fails?

    The most likely cause is that you aren't setting the expiry date.

    Mike

    --
    Michael Winter
    M.Winter@blueyo nder.co.uk.invalid (remove ".invalid" to reply)

    Comment

    • F@bio

      #3
      Re: document.cookie on Opera and IE for Mac..

      > Describe, "ignored". It doesn't appear in the cookie list,
      or[color=blue]
      > retrieving a value, in the same session, fails?[/color]

      ....retrieving a value, in the same session, fails. Hope I'm
      saying somthing stupid but I think the cookie doesn't get
      written, it just stays in the memory.

      Anyway, here I published an example:


      [color=blue]
      > The most likely cause is that you aren't setting the[/color]
      expiry date.

      I'll try this way...

      F@bio



      Comment

      • Michael Winter

        #4
        Re: document.cookie on Opera and IE for Mac..

        F@bio wrote on 04 Dec 2003:
        [color=blue]
        > Anyway, here I published an example:
        > http://globalmoments.firenze.net/cookie_e.htm[/color]

        I'd like to point out that that page works fine in Opera 7 (Win).

        Your page (reformatted slightly):

        You haven't included a DOCTYPE declaration. Before the HTML element,
        you should include either this:

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">

        or this:

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">

        depending upon what elements and attributes you use. The latter is
        preferable, but you'll probably need to change how you author pages.

        <html>
        <head>
        <title>Cookie Test</title>
        <script language="javas cript">

        The attribute, language, is deprecated and doesn't need to be used.
        The type attribute, however, is /required/ and must be used. Change
        that line (and the one later) to:

        <script type="text/javascript">

        function updateCookie() {

        Neither of these two statements below have terminating semi-colons
        (;). That could be part of your problem, but as I said, it worked
        nevertheless.

        document.cookie =document.myfor m.cookie.value

        To access form elements, you should use the 'collection' syntax. It
        works across more browsers:

        document.cookie = document.forms['myform'].elements['cookie'].value;

        Note the semi-colon, above.

        location.reload (true)
        }
        </script>

        You don't declare the default scripting language, which you /must/ do
        if you use intrinsic events (onclick, etc). Add this:

        <meta http-equiv="Content-Script-Type" content="text/javascript">

        </head>

        <body>
        <script language="javas cript">

        Again, no type attribute (above) and no semi-colon (below).

        document.write( "Cookie value: "+document.cook ie)
        </script>
        <form action="" name="myform">
        <p>Definy the cookie value: <input type="text" size="60"
        name="cookie"></p>
        <input type="button" name="setCookie " value="Set Cookie"
        onClick="update Cookie()">
        </form>
        <hr>
        On Internet Explorer 5 for Mac (OS 9) and Opera 6 for PC doen't
        seem to work!
        </body>
        </html>

        Try these changes and test the page for yourself again: I can't - I
        only have IE6 and Opera 7 (both Win), and it works in both of them.

        Good luck,
        Mike

        --
        Michael Winter
        M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk")

        Comment

        Working...