Join David Powers for an in-depth discussion in this video Writing session data, part of Managing PHP Persistent Sessions.
- We've added the code for the…Open and the Read Methods to the…My SQL Session Handler class.…Next we'll deal with the Write Method.…The code for this is much simpler…than the Read Method.…So, let's just scroll down to find…the signature for the Write Method.…Here it is, it takes two parameters,…the session ID and the session data.…As with all the methods in the session handler interface,…PHP obtains these values automatically.…The session data, having been retrieved by the…Read Method that we scripted in the previous video,…and potentially added to by the creation…or updating of session variables.…
So what we need to do is to write…to the database and then return…a bullion troop.…I've got all the necessary code in this file…Write.TXT which you can find in the…exercise files for this video.…Just select everything, copy it,…go back to Mysqlsessionhandler.PHP…and then paste it into the Write Method.…Everything is wrapped in a try-catch structure,…and the try-block creates and executes…a prepared statement to write…the session data to the database.…
- 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.