最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Where are cookies saved for a local HTML file? - Stack Overflow

programmeradmin5浏览0评论

I created an HTML file on my desktop and added some JavaScript to set and clear cookies.

Now my question is, will the cookie be saved in my browser? Can I read it back?

if Yes,

  • For which domain will it be saved?

  • How can I see it in Google Chrome? (HTML run on Chrome)

I created an HTML file on my desktop and added some JavaScript to set and clear cookies.

Now my question is, will the cookie be saved in my browser? Can I read it back?

if Yes,

  • For which domain will it be saved?

  • How can I see it in Google Chrome? (HTML run on Chrome)

Share Improve this question edited Nov 5, 2017 at 7:06 trincot 351k36 gold badges271 silver badges322 bronze badges asked Dec 22, 2011 at 10:55 techBeginnertechBeginner 3,85012 gold badges44 silver badges61 bronze badges 3
  • 1 Unfortunately some browsers including Google Chrome do not store cookies from local web pages: stackoverflow./questions/335244/… – paulcol. Commented Dec 22, 2011 at 10:59
  • In Opera you can view and edit cookies in the settings-page. Worth a shot (unless you have to use Chrome) – OptimusCrime Commented Dec 22, 2011 at 10:59
  • actually I am going to use that HTML file for my own chrome extension.. fortunately setting cookie works there.. it uses extension ID instead of domain. – techBeginner Commented Dec 22, 2011 at 12:34
Add a ment  | 

2 Answers 2

Reset to default 12

Unfortunately some browsers including Google Chrome do not store cookies from local web pages:

  • Why does Chrome ignore local jQuery cookies?

Firefox has great developer plugins for cookie management, which report their domains, access paths and expiry:

  • https://addons.mozilla/en-US/firefox/addon/view-cookies/
  • https://addons.mozilla/en-US/firefox/addon/firecookie/ (Personal Favourite - Requires FireBug)

For local development purposes you can setup a development domain like "localhost" or "myfakedomain." and run your files on a local server.

Search:

  • Editing Hosts File [operating system]
  • Setup Local server on [operating system] (I use xampp)

If you're running the 'site' on a local webserver then it should be stored in your browser under 'localhost'. If however you're just opening a static HTML file Chrome will not store the cookie.

In Chrome you can use the Chrome Developer Tools and look under the 'Resources' tab.

发布评论

评论列表(0)

  1. 暂无评论