Page 1 of 1

when do cookie write to disk?

Posted: Sun Apr 22, 2012 8:46 pm
by wvoyance
I am reading a book of Morrison, which tell me that cookie is write to disk when the browser is turned off.
But my understanding is that when cookie is created.
Anyone knows which one is right? Thanks.

Re: when do cookie write to disk?

Posted: Sun Apr 22, 2012 11:16 pm
by requinix
Depends on the browser.

Re: when do cookie write to disk?

Posted: Mon Apr 23, 2012 8:40 am
by wvoyance
could you please tell me which browser is which. How can I find out the policy of my browser?

Re: when do cookie write to disk?

Posted: Mon Apr 23, 2012 9:03 am
by requinix
No, because I don't know. And I'd be very surprised if anybody who doesn't actually write code for a browser knew.

As for finding out, your options are:
- Download the source of the various browsers (the ones that provide source) and see what the code does
- Ask on a mailing list and/or forum dedicated to the development of each browser
- Google it

Re: when do cookie write to disk?

Posted: Mon Apr 23, 2012 9:42 am
by social_experiment
wvoyance wrote:I am reading a book of Morrison
Which book, Javascript Bible?

Re: when do cookie write to disk?

Posted: Mon Apr 23, 2012 5:00 pm
by pickle
The cookie is created the moment the browser receives the headers telling it to create a cookie. That cookie is stored in RAM. At various times (dependant on the browser), that cookie will be written to hard disk so it can be stored long term. As far as a web developer is concerned, when this happens doesn't matter. Nothing changes as far as the data that can be accessed or stored via the cookie.

Re: when do cookie write to disk?

Posted: Tue Apr 24, 2012 1:54 am
by social_experiment
Found this in the aforementioned book
As you experiment with browser’s cookies, you will be tempted to look into the cookie file after a script writes some data to the cookie. The cookie file usually will not contain the newly
written data, because in most browsers cookies are transferred to disk only when the user quits the browser; conversely, the cookie file is read into the browser’s memory when it is launched. While you read, write, and delete cookies during a browser session, all activity is performed in memory (to speed up the process) to be saved later.

Re: when do cookie write to disk?

Posted: Tue Apr 24, 2012 3:23 am
by wvoyance
social_experiment wrote:
wvoyance wrote:I am reading a book of Morrison
Which book, Javascript Bible?
Head First Javascript byMichael Morrison on Chapter 3 when it talk about cookie there is a picture.

What I read is a translate version, therefore cannot tell you exactly ISBN and page number.

Re: when do cookie write to disk?

Posted: Tue Apr 24, 2012 3:29 am
by wvoyance
social_experiment wrote:Found this in the aforementioned book
As you experiment with browser’s cookies, you will be tempted to look into the cookie file after a script writes some data to the cookie. The cookie file usually will not contain the newly
written data, because in most browsers cookies are transferred to disk only when the user quits the browser; conversely, the cookie file is read into the browser’s memory when it is launched. While you read, write, and delete cookies during a browser session, all activity is performed in memory (to speed up the process) to be saved later.
Later in the same book, there is a talk between "variable" and "cookie" which I do not think quite right.
They said cookie use table while variable not. Actually compiler generate table for variables.