document.cookie on Opera and IE for Mac..

F

F@bio

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
 
M

Michael Winter

F@bio wrote on 03 Dec 2003:
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?

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
 
F

F@bio

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

....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:
http://globalmoments.firenze.net/cookie_e.htm

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

I'll try this way...

F@bio
 
M

Michael Winter

F@bio wrote on 04 Dec 2003:

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="javascript">

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.myform.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="javascript">

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

document.write("Cookie value: "+document.cookie)
</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="updateCookie()">
</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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top