Cookie and Session Tutorial

Posted on Monday, October 04, 2004 @ 23:33:43 UTC in PHP
by Raven

Vikram Vaswani - PhP101 series has a pretty good tutorial at Zend.com on Cookies and Sessions that may be of value to you.

Party Time

Maybe you heard this at the last party you went to: "HTTP is a stateless protocol, and the Internet is a stateless development environment".

No? Hmmm. Obviously, you don't go to the right parties.

In simple language, all this means is that HTTP, the HyperText Transfer Protocol that is the backbone of the Web, is unable to retain a memory of the identity of each client that connects to a Web site, and therefore treats each request for a Web page as a unique and independent connection, with no relationship whatsoever to the connections that preceded it. This "stateless environment" works great so long as you're aimlessly surfing the Web, but it can cause a serious headache for sites that actually depend on the data accumulated in previous requests. The most common example is that of an online shopping cart - in a stateless environment, it becomes difficult to keep track of all the items you've shortlisted for purchase as you jump from one catalog page to another.

Obviously, then, what is required is a method that makes it possible to "maintain state", allowing client connections to be tracked and connection-specific data to be maintained. And thus came about cookies, which allow Web sites to store client-specific information on the client system, and access the information whenever required. A cookie is simply a file, containing a series of variable-value pairs and linked to a domain. When a client requests a particular domain, the values in the cookie file are read and imported into the server environment, where a developer can read, modify and use them for different purposes. A cookie is a convenient way to carry forward data from one client visit to the next.
 
 
click Related        click Share
 
 
Associated Topics

Documentation
 
News ©

Site Info

Last SeenLast Seen
  • neralex
  • nextgen
Server TrafficServer Traffic
  • Total: 481,641,618
  • Today: 8,920
Server InfoServer Info
  • Mar 29, 2024
  • 06:29 am UTC