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

Invisible cookies with Javascript for IE 6

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

---
http://www.wiesenblume.at
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In article <c4**************************@posting.google.com >,
w.******@gmx.at (Wolfgang Adamec) wrote:
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;
}


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:

http://groups.google.com/groups?hl=e...859-1&selm=MPG
..1af96c2a4f8abc94989dcc%40nntp.lucent.com

Also, ~kaeli~ reports that:
There's some even better code that sets more cookie properties like
domain, secure, path, etc here.
http://www.acm.uiuc.edu/webmonkeys/j...ipt/cookies.js

Robert
Jul 23 '05 #2

P: n/a
Robert <rc*******@my-deja.com> writes:
document.cookie = name+"="+val;
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:
---
document.cookie = "hello=world";
document.cookie = "world=now";
alert(document.cookie);
---

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #3

P: n/a
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<ad**********@hotpop.com>...
Robert <rc*******@my-deja.com> writes:
document.cookie = name+"="+val;

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.


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

Robert
Jul 23 '05 #4

P: n/a
..

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
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.