Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are cookies saved for a local HTML file?

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)

like image 383
dotNETbeginner Avatar asked Dec 22 '11 10:12

dotNETbeginner


People also ask

Where are cookies stored in HTML?

When a browser requests a web page from a server, cookies belonging to the page are added to the request. This way the server gets the necessary data to “remember” information about users. The <meta> tag can be used to store cookies on this side of the client.

Where are your cookies stored?

If you're wondering “where are cookies stored,” it's simple: your web browser will store it locally to remember the “name-value pair” that identifies you. If a user returns to that site in the future, the web browser returns that data to the web server in the form of a cookie.

How do I open a local cookie file?

In such a browser as Mozilla Firefox, you can see the cookies in the browser settings. For this, you just need to click on the Open menu > Web Developer. In Google Chrome you can find cookie files entering chrome://settings/content/ Cookies in the address bar.


2 Answers

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.

like image 27
isNaN1247 Avatar answered Oct 03 '22 17:10

isNaN1247


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.org/en-US/firefox/addon/view-cookies/
  • https://addons.mozilla.org/en-US/firefox/addon/firecookie/ (Personal Favourite - Requires FireBug)

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)
like image 123
paulcol. Avatar answered Oct 03 '22 17:10

paulcol.