You are here: Home » Tutorials » Web Development » PHP » Cookies and Sessions » How to use Cookies wih PHP..

How to use Cookies wih PHP

Added January 26, 2008, read 521 times

Page 1. Navigate to page: 1 2

Using Cookies with PHP

Learn how to set a cookie, extract data from a cookie, amend your user authentication routines to use a cookie.

What are Cookies?

Cookies are pieces of text that are sent to a user's web browser. Cookies can help you create shopping carts, user communities, and personalized sites. It's not recommended that you store sensitive data in a cookie, but you can store a unique identification string that will match a user with data held securely in a database.

Take the shopping example. Suppose you assign an identification variable to a user so that you can track what he does when he visits your site. First, the user logs in, and you send a cookie with variables designed to say, "This is Joe, and Joe is allowed to be here." While Joe is surfing around your site, you can say, "Hello, Joe!" on each and every page. If Joe clicks through your catalog and chooses 14 items to buy, you can keep track of these items and display them all in a bunch when Joe goes to the checkout area.

Page 1. Navigate to page: 1 2

Discuss

  • Your name
  • Your email (we'll keep this to ourselves)
  • What's it about?
  • Security check

Nobody posted any comments regarding this story. Be the first!