Set cookies in documents loaded from local filesystem

T

Thomas Krebs

Is it possible to set a cookie in a HTML file which is loaded from the
local filesystem (protocol is 'file:' instead of 'http')?
It seems that I can set the cookie and I am also able to access it as
long as I do not close the browser. After I close the browser, the
cookie isn't there anymore.
I could not find it in the cookie file either.

Thanks for any help,
Thomas
 
K

kaeli

Is it possible to set a cookie in a HTML file which is loaded from the
local filesystem (protocol is 'file:' instead of 'http')?
It seems that I can set the cookie and I am also able to access it as
long as I do not close the browser. After I close the browser, the
cookie isn't there anymore.
I could not find it in the cookie file either.



Sounds like you forgot to set an expires date, making it a session
cookie that goes away when you close the browser.

--
 
M

Michael Winter

Thomas Krebs wrote on 25 Nov 2003:
Is it possible to set a cookie in a HTML file which is loaded
from the local filesystem (protocol is 'file:' instead of
'http')? It seems that I can set the cookie and I am also able
to access it as long as I do not close the browser. After I
close the browser, the cookie isn't there anymore.
I could not find it in the cookie file either.

I've used local cookies in both of my browsers (Opera and IE) when
testing and they are stored.

It sounds like you didn't set the expiry date when you added the
cookie. If you set it manually (using document.cookie), make sure
that the date is *not* quoted, and is of the form:

Wdy, DD-Mon-YY HH:MM:SS GMT

For example: EXPIRES=Thu, 27-Nov-2003 14:30:00 GMT

The Netscape cookie standard (not RFC 2109) expected a two-digit
year, but I imagine all modern browsers will (and should) accept the
full four.

Most setCookie functions use a Date object set to the expiry date,
rather than a string.

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,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top