From the course: PHP: Object-Oriented Programming with Databases

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Improve the session class

Improve the session class - PHP Tutorial

From the course: PHP: Object-Oriented Programming with Databases

Start my 1-month free trial

Improve the session class

- [Instructor] Before we leave this topic completely, I want us to make a few improvements to our session class. Hopefully this will help to illustrate why it's useful to wrap up some of that session functionality into a class in the first place. Putting all of that code into the session class allowed us to have it all in one place, but it also allows us to be able to extend this class and to do more work on it in the future, so it would become more complex over time and helps us to manage that complexity. For example, let's say that we wanted to have the current user's username displayed up here at the top, so it would just say who you're logged in as. Well, we could add that feature by simply adding a new public attribute for username. Let's say that we also wanted to keep track of when the user last logged in. We'll make a private attribute for their last_login. The idea might be that we don't want to allow users to stay logged in forever. At a certain point, we want their login to…

Contents