5

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)

trincot
  • 263,463
  • 30
  • 215
  • 251
dotNETbeginner
  • 3,582
  • 9
  • 41
  • 59
  • 1
    Unfortunately some browsers including Google Chrome do not store cookies from local web pages: http://stackoverflow.com/questions/335244/why-does-chrome-ignore-local-jquery-cookies – paulcol. Dec 22 '11 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 Dec 22 '11 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. – dotNETbeginner Dec 22 '11 at 12:34

2 Answers2

12

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

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

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

Search:

  • Editing Hosts File [operating system]
  • Setup Local server on [operating system] (I use xampp)
Community
  • 1
  • 1
paulcol.
  • 2,691
  • 1
  • 20
  • 18
1

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.

isNaN1247
  • 17,513
  • 12
  • 69
  • 116
  • I have not created any site. I have just created an html file..I don't know if its running under `local webserver`, I am just double clicking the html file and it runs on my default browser.. – dotNETbeginner Dec 22 '11 at 11:01
  • I don't find anything under `Resources` tab – dotNETbeginner Dec 22 '11 at 11:02
  • 1
    In which case you [won't have the cookies stored](http://stackoverflow.com/questions/335244/why-does-chrome-ignore-local-jquery-cookies) as per crolpa's comment above. – isNaN1247 Dec 22 '11 at 11:02