PHP Cookies

In this chapter you will learn:

  1. What is a cookie
  2. Lifespan for a cookie
  3. Note for cookie

Description

A cookie lets you store a small amount of data(no more than 4KB) within the user's browser itself. Then, when the browser requests a page, all the data in the cookie is automatically sent to the server within the request.

You can send the data once to the browser, and the data is automatically available to your script from that moment onward.

Lifespan

You can make a cookie last for a fixed amount of time, from a few seconds to several years. Or you can set a cookie to expire once the browser application is closed.

Most modern browsers can store up to 30 cookies per Web site domain.

Note

We shouldn't rely on the data in cookies alone to identify or authenticate your users.

It's easy to turn off cookie support in most browsers. And Web site shouldn't rely on cookies for essential functionality. Or it should prompt the user to enable cookies for your web site if necessary.

Next chapter...

What you will learn in the next chapter:

  1. HTTP Header
  2. Cookie Component
  3. Note for cookie domain
Home » PHP Tutorial » PHP Cookie
PHP Cookies
PHP Cookie Components
PHP setcookie() function
PHP Access Cookies
PHP Remove Cookies