Join David Powers for an in-depth discussion in this video Defining tables to store session data, part of Managing PHP Persistent Sessions.
- We need three tables in the database:…one for storing user credentials,…and the other two for the Persistent sessions.…This is persistent.sql which you can find…in the exercise files for this video.…It contains the SQL statements to create the tables.…The file doesn't specify which database to use,…so you could use it with any database.…So let's take a quick look at the structure of each table.…The first one is called users.…The first column, user_key, is a fixed-width string column…that will store eight characters.…
This will be the table's primary key.…Instead of using auto-increment,…the primary key will be a randomly generated,…eight-character alphanumeric string.…The next column, username, will be a variable-length string…of up to 30 characters, and it will have a unique index.…That'll prevent the same username…being chosen by another person.…The password column, pwd, will also be…a variable-length string of up to 255 characters.…
The reason for using such a long string…is that we'll be using the PHP password-hashing API.…
- 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
Skill Level Intermediate
Accessing Databases with Object-Oriented PHPwith David Powers3h 47m Intermediate
1. Sessions and Security
2. Preparing the Database
Connecting to the database5m 49s
3. Storing Session Data in MySQL
4. Creating an Autologin System
5. Testing the Autologin System
Final thoughts3m 9s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.