After reading some guides on the topic I decided I'd create a custom session handler class. But I've ran into an odd problem. The class was designed to store all Session information in a MySQL database. I know there are probably more efficient ways but right now I'm trying to figure out what I'm doing wrong.
Basically the problem I'm having is that the read() function of my Session wrapper class is being called BEFORE write(). Essentially it is trying to look for information that has yet to be written to the database. From reading the documentation of set_session_save_handler the only times write() is called is when PHP is closed or when session_write_close() is called. But that doesn't exactly help me here! I don't want to write() at the END of the session, that's useless! I'm trying to write() information then retrieve it (with read()) whenever I access $_SESSION data.
Am I thinking about this completely wrong? I appreciate any help! Here's the section of code where I'm using my custom session wrapper. If you need the actual wrapper code let me know:
public function login()
$username = $_POST['txt_username'];
$password = $_POST['pwd_username'];
//TO-DO: Need to pass in the ID of the user being authenticated.
//To do this though will need a new function in the DB class that
$session = new SessionEngine($session_config);
$_SESSION['auth'] = true;
$_SESSION['username'] = $username;
error_log("******** Session data: ".var_export($_SESSION), 0);