Join David Powers for an in-depth discussion in this video Implementing persistent sessions, part of PHP: Managing Persistent Sessions.
- This is the approach I propose…for Implementing Persistent Sessions.…The requirements are that the data must be stored securely.…That means using a database rather than plaintext files.…We need a cookie that persists…even after the browser is closed.…Although the idea behind persistent sessions…is to recognize returning users,…automatic login should be an option, not the default.…Session data should also be accessible…from different devices,…and the user should be able to log out.…
The session data needs to be stored in a database.…One option is to register SQLite as the session handler.…There are several problems with this.…SQLite was removed from PHP 5.4…and has been superseded by SQLite3,…but support for session handling with SQLite3…has never been implemented.…Moreover, SQLite database files aren't password protected,…so they're not secure.…Consequently we'll use MySQL to store the data.…
This will involve writing our own session handler,…but it offers greater security.…The same code will also work with MariaDB,…
- 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
PHP: Accessing Databases with PDO and MySQLiwith 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.