Learn how to set a cookie, extract data from a cookie, amend your user authentication routines to use a cookie.
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.
Type in the field on the left the code displayed on the image below.
Nobody posted any comments regarding this story. Be the first!
Discuss