PHP: Managing Persistent Sessions
2h 42mIntermediate2015-07-02
Authors

David Powers
Developing websites since 1994
Course details
PHP persistent sessions allow for communication between the server and client. This allows web applications to remember the identities of visitors as well as any variables or other data. This practical and challenging project-based course will help developers take the data that PHP normally stores in plain text files and write them into a more secure database, where the records can be read and destroyed as needed. Author David Powers helps you set up a SQL database, define classes to open and close sessions, read and write variables, destroy sessions, and manage out-of-date records. The lessons culminate in a short project that uses tokens to recognize returning users in an auto-login scenario.
Learning objectives
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
Learning objectives
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
Skills covered
PHPProgramming LanguagesOpen SourceSoftware DevelopmentDeep Dive (X:Y)
Concepts
0. Introduction
- 01 - Welcome
- 02 - What you should know before watching this course
- 03 - Using the exercise files
- 04 - Sessions in Google Chrome
1. Sessions and Security
- 05 - How PHP sessions work
- 06 - Configuring session
- 07 - Changing session defaults
- 08 - Inspecting how session data is stored
- 09 - Implementing persistent sessions
2. Preparing the Database
- 10 - Creating a database and user account in MySQL
- 11 - Defining tables to store session data
- 12 - Connecting to the database
3. Storing Session Data in MySQL
- 13 - Implementing the PHP SessionHandlerInterface
- 14 - Opening a session and reading stored data
- 15 - Writing session data
- 16 - Closing the session and garbage collection
- 17 - Destroying the session
- 18 - Setting the session handler
4. Creating an Autologin System
- 19 - How the autologin system works
- 20 - Using a trait to define common properties
- 21 - Extending the MysqlSessionHandler class
- 22 - Creating a persistent login
- 23 - Checking a returning visitor's credentials
- 24 - Logging out
5. Testing the Autologin System
- 25 - Generating a unique key when registering users
- 26 - Using a PSR-4 class autoloader
- 27 - Authenticating the user
- 28 - Revalidating credentials for sensitive areas
- 29 - Logging out selectively
Conclusion
- 30 - Final thoughts
Related courses
- PHP with MySQL Essential Training: 2 Build a CMS
- Learning PHP: Building Dynamic Websites from Core Concepts to Applications
- Building APIs in PHP Using the Slim Micro Framework
- Installing Apache, MySQL, and PHP
- Building Laravel and Vue.js 2 Web Apps
- Learning Shopify
- TeamCity 2017 Essential Training
- Learning Eclipse