when do cookie write to disk?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
wvoyance
Forum Contributor
Posts: 135
Joined: Tue Apr 17, 2012 8:24 pm

when do cookie write to disk?

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: when do cookie write to disk?

Post by requinix »

Depends on the browser.
User avatar
wvoyance
Forum Contributor
Posts: 135
Joined: Tue Apr 17, 2012 8:24 pm

Re: when do cookie write to disk?

Post by wvoyance »

could you please tell me which browser is which. How can I find out the policy of my browser?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: when do cookie write to disk?

Post 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
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: when do cookie write to disk?

Post by social_experiment »

wvoyance wrote:I am reading a book of Morrison
Which book, Javascript Bible?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: when do cookie write to disk?

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: when do cookie write to disk?

Post 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.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
wvoyance
Forum Contributor
Posts: 135
Joined: Tue Apr 17, 2012 8:24 pm

Re: when do cookie write to disk?

Post 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.
User avatar
wvoyance
Forum Contributor
Posts: 135
Joined: Tue Apr 17, 2012 8:24 pm

Re: when do cookie write to disk?

Post 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.
Post Reply