Join David Powers for an in-depth discussion in this video Checking a returning visitor's credentials, part of PHP: Managing Persistent Sessions.
- We'll continue our examination of the AutoLogin class…by looking at the public checkCredentials method…which begins on line 130 of AutoLogin.php.…This method is called whenever a user tries…to access a restricted page without first logging in.…It verifies whether a persistent session exists.…And, it does so by checking the cookie superglobal array…to see if an AutoLogin cookie has been presented…by the browser.…If it hasn't the method does nothing,…however if the cookie exists the checkCredentials method…invokes a series of helper methods.…
We'll look at them in a moment,…but first let's run through the process.…The parseCookie method returns the single use token…stored in the cookie.…If a token is found the clearOld method deletes all…expired tokens before checking the current one any further.…The token is then passed to the checkCookieToken…method with false as the second argument.…This returns true if the token is valid…and hasn't been used before.…
If the token is okay the cookieLogin method…logs the user in automatically.…
- 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.