Online
 
Friday, 09 January 2009
 
 
More article:
Related Content:

Your Ad Here

php HTTP Cookies
 
Article Index
php HTTP Cookies
Page 2

Although quite useful as a protocol, HTTP is known in the computer science world as a "stateless" protocol. If that doesn't make sense to you, don't worry. Unlike your favorite programs that you run on your desktop, such as a word processor, PHP has no way of remembering a past request. The only information PHP has available to it when a script is executed is the information it was provided during the HTTP request. For example, what if you wanted to make a website that remembers the first name of every visitor and uses it to generate personalized content from your PHP scripts? How would you distinguish one visitor from another one in your PHP scripts? Cookies are used to solve this problem in a (fairly) eloquent way.

If you're still not sure how cookies work, consider the concept of valet parking. When you pull up, the staff gives you a ticket and goes and parks your car. After you have eaten your meal or have seen your show, you return to the staff and present them with your ticket and they get your car. Now, if you didn't have that ticket, how would the staff know which car was yours? Furthermore, if you don't have a ticket, how does the staff know you ever parked a car in the lot in the first place? This concept of a valet parking ticket is exactly how cookies work. When you visit a website, the server gives you a cookie that identifies you. Next time you visit the website (or even go to another page on that website) you give that cookie back to the server and it uses it to determine who you are.



Tags: Add more tags...,
This entry was posted on . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a comment. Tags: Simple PHP, Pear, Easy PHP, PHP Tutorial, PHP MySQL, XSLT, Sap Tutorial, CSS Tutorial, XSL FO Java, SQL Tutorial.
Users' Comments (0)

Comment an article
  Name
  E-mail
   Title
Available characters: 4000
 Notify me of follow-up comments
This image contains a scrambled text, it is using a combination of colors, font size, background, angle in order to disallow computer to automate reading. You will have to reproduce it to post on my homepage
Enter what you see:

No comment posted

Wallpaper 66
Statistic


Last Post

 
Top! Top!