By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,599 Members | 1,872 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,599 IT Pros & Developers. It's quick & easy.

document.cookie on Opera and IE for Mac..

P: n/a
F
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


Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

--
Michael Winter
M.******@blueyonder.co.uk.invalid (remove ".invalid" to reply)
Jul 20 '05 #2

P: n/a
F
> 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

Jul 20 '05 #3

P: n/a
F@bio wrote on 04 Dec 2003:
Anyway, here I published an example:
http://globalmoments.firenze.net/cookie_e.htm


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

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.