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.

Set cookies in documents loaded from local filesystem

P: n/a
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
Share this Question
Share on Google+
2 Replies


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

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