470,638 Members | 1,581 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,638 developers. It's quick & easy.

Set cookies in documents loaded from local filesystem

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
Jul 20 '05 #1
2 2141
In article <23**************************@posting.google.com >,
th**********@deutsche-boerse.com enlightened us with...
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.

--
--
~kaeli~
Every calendar's days are numbered.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2
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

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

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Miguel | last post: by
2 posts views Thread by kublai khan | last post: by
3 posts views Thread by Alex Nitulescu | last post: by
1 post views Thread by Alex Nitulescu | last post: by
10 posts views Thread by Stephan Schulz | last post: by
5 posts views Thread by yawnmoth | last post: by
3 posts views Thread by mosesdinakaran | last post: by
2 posts views Thread by TuftyTrue | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.