Chapter 22. Using Session Control in PHP

In this chapter, we discuss the session control functionality in PHP.

Key topics covered in this chapter include

  • What session control is

  • Cookies

  • Steps in setting up a session

  • Session variables

  • Sessions and authentication

What Session Control Is

You might have heard people say that “HTTP is a stateless protocol.” This means that the protocol has no built-in way of maintaining state between two transactions. When a user requests one page, followed by another, HTTP does not provide a way for you to tell that both requests came from the same user.

The idea of session control is to be able to track a user during a single session on a website. If you can do this, you can easily support logging in a user and showing content ...

Get PHP and MySQL Web Development, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.