Join David Powers for an in-depth discussion in this video What you should know before watching this course, part of Managing PHP Persistent Sessions.
- View Offline
- This is not a beginner's course, so you need to have a solid grasp of PHP syntax, including the use of control structures, loops, and arrays. You should also be comfortable working with PHP classes and objects. Nearly all of the code in this course is object oriented. We'll be storing sessions data in a database, so you should understand basic SQL for select, insert, update, and delete queries. A lot of the code uses PDO-prepared statements with named parameters to submit queries to the database, so you should be familiar with using PDO.
If you feel your knowledge on any of these subjects isn't up to scratch, I've got some suggestions for courses that should put you on the right track. But, before that, let's take a look at the setup required for following this course. Ideally, you need a testing server running PHP 5.5 or later, although PHP 5.4 will do. This is because code uses the PHP password hashing API that requires a minimum of PHP 5.5. To enable password hashing in PHP 5.4, you need to include the password_compat library in your scripts.
This is a single file that you can download from github at this URL. I also recommend that you enable display errors in your testing environment, either by editing the main configuration file, php.ini, or with with an .htaccess file if you're running Apache. You'll also need a MySQL or MariaDB database. I've deliberately restricted the choice of database to avoid making the code more complex than absolutely necessary, and if you plan to follow along with me with the coding, you'll also need a text editor.
I'll be using PhpStorm, but it doesn't matter which one you use, choose whatever suits your workflow best. Now, if you don't think you're ready for this course, here are a few suggestions to get you up to speed. If you're new to PHP, try one of the beginner courses in the lynda.com online training library, as my Introducing PHP and Kevin Skoglund's PHP with MySQL Essential Training. For a solid introduction to working with classes and objects, take a look at Jon Peck's course, Object-Oriented Programming with PHP.
If you need help with PDO-prepared statements, the first three chapters of my accessing databases with object orientated PHP have you covered. And, if you need to brush up your knowledge of SQL, you won't go wrong with Bill Weinman's MySQL Essential Training. Then come back here and join in the fun of managing PHP persistent sessions.
- Configuring sessions
- Inspecting how session data is stored
- Implementing persistent sessions
- Creating a SQL database to store session data
- Implementing the PHP SessionHandlerInterface
- Writing session data
- Closing and destroying sessions
- Creating an auto-login system with persistent sessions
- Creating persistent logins
- Checking out visitor credentials
- Authenticating users
- Logging out users selectively