Join David Powers for an in-depth discussion in this video Authenticating the user, part of PHP: Managing Persistent Sessions.
- At the beginning of this chapter,…registering a new user took us straight to the login page.…We need to add the code to authenticate the user,…so open login.php in the test folder.…First thing we need to do is to create a php block…above the docType and include the file that we created…in the previous video to load the class definitions…and set the session handler.…There we are above the docType.…New php block,…and then require_once…and the file that we need to include…is in the includes folder,…and it's called init.php.…
The login page needs to use the auto login class,…so we need to import it with use operator.…So use then Foundationphp…\Sessions\AutoLogin.…It's important to note that the use operator…scope is limited to individual files.…Include files don't inherit the parent…file's importing rules nor can the parent file…use the importing rules of an include file.…So that's why I've had to declare it here.…
To save time, I'm going to copy the rest of the login code…from this file login.txt,…which you can find in the Chapter05,…
- 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.