Join David Powers for an in-depth discussion in this video Creating a persistent login, part of PHP: Managing Persistent Sessions.
- The autologin class creates persistent sessions…and logs in users automatically.…The class definition, including comments,…is more than 360 lines.…So rather than type it all out,…I'll explain how it works over the next few videos.…There's a copy of Autologin.php in the Chapter 4…04_04 folder of the exercise files.…The class uses the Foundationphp\Sessions name space,…so we need to copy it to Foundationphp Sessions folder…in the testing site route.…
Let's quickly do that.…This long comment at the top of the file…is the MIT license that allows you…to modify and redistribute the code.…Let's just fold that away.…And then I'm going to expand this pane…so we can see the code more clearly.…The autologin class shares many common properties…with the Persistent SessionHandler class…that was defined in the previous video.…So the class definition begins…by importing the PersistentProperties trait…with the use operator.…
Next, several other properties are declared.…They are all commented, so I won't describe them in detail.…
- 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?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.