Invisible cookies with Javascript for IE 6

W

Wolfgang Adamec

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('firstname','michael');

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
 
L

Lasse Reichstein Nielsen

I suggest using an existing set of cookie routines. The document.cookie
can contain existing cookies and you need to preserve them.

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:
 
R

Robert

..
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.

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
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top