Varsha Agarwal wrote:
> Can anyone tell me what a cookie is in simple language
> with an example??
A web connection is made by two machines:
1) the server, where the site is
2) the client, that is, the machine at which sits the user
Once the client sends a request for a web page (an URL, in tech
language) some sort of program gets executed on the server. At the very
least a program called "Web Server" will receive the request, look for a
file that has that name and send it back to the client.
But usually the file does not end in .html, so something more gets
executed, like PHP.
Well, this new thing being executed may need to write data somewhere,
and it usually does write it in a database (that is, a set of tables).
When it does so, it writes data on the server, that is, the very same
machine it is running on.
But for some reasons it is sometimes useful to write data on the remote
machine, that is, the client. This process of writing data on the client
machine is called "sending a cookie".
The client machine may actually accept or refuse doing so, the server
cannot know that, so no important data should ever be written in a
cookie, as it may not get written.
Now suppose I (the program coder) need to now that you like to receive
pages with lots of flowers and hate to receive pages with lots of
machine code diagrams. I put a menu on my page and let you choose,
right? Only it would be nice, if the next time you come to visit the
site you were immediately presented the pages you like.
But, unfortunately, I have no way to stock this information on the
server, because I cannot associate it with you in anyway (thank god,
otherwise bye bye privacy).
So what I do is writing on a cookie that you like flower pages and hate
machine code diagrams.
Next time the client machine (your comp) will connect to my site it will
first look in its cookies list. It will find that there is a cookie for
this particular site and send it to the server along with the request.
Bingo! now I know you hate machine code diagrams.
I oversimplified, of course, cookies have much more than just this. Thay
have expiration dates, limits on directory tree validity and so on, but
that's the root of it.
LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu?
lOrD i'M sHiNiNg...
YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is.......
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php