Sessions
The Hypertext Transfer Protocol (HTTP) is stateless, which vastly simplifies its implementation because a web server does not retain information across requests. Unfortunately, web applications require maintaining state – e.g., to implement a shopping cart. Cookies and sessions are two ways to maintain state about a user’s interactions to overcome this limitation of HTTP.
Learning Objectives
- Describe an HTTP cookie
- Use PHP sessions to implement authentication for web pages
- Compare and contrast HTTP cookies and PHP sessions to track state
How to Complete this Lesson
- Read HTTP cookies (10–15 minutes)
- Review the handout (10–15 minutes)
- Optional: Read about the following Web APIs that provide alternatives to
cookies for client-side storage
- Web Storage API (5 minutes)
- IndexedDB (5–10 minutes)
- Complete the web development programming exercise (PEX)
(120 minutes)
- Create an alternative CSS theme
- Add feature(s) to the website
Due
As a reminder, the following is due this lesson: