Hello,
I'm writing a quick roll-your-own blog to get back into the swing of webdev, and I've hit a snag. I'm trying to use session_set_save_handler to use a custom class of functions, implementing SessionHandlerInterface, to save sessions to a PostgreSQL database table via PDO. I've added die() at every point I think it could be failing but no errors are reported. I checked nginx, php-fpm, and postmaster logs, nothing. The thing I'm trying to debug is the fact that no rows are inserted to the database after setting a random test variable in $_SESSION and calling session_write_close(). I know the script is successfully connecting to the database because no exceptions or errors are thrown, so there must be some error that isn't being reported by PDO or the session handler.
Basically PDOStatement::rowCount() is returning > 0 for a query inserting a row into the sessions table but upon a SELECT * on said table nothing is there.
So I've attached/bpaste'd the relevant files. Here's what's in them:
index.php: the script that runs everything
database.php: database functionality
main.php: instantiates database for session & other classes. also contains the function to test session/database functionality
sessions.php: class implementing SessionHandlerInterface
SQL for the sessions table:
CREATE TABLE sessions (
session_id bytea PRIMARY KEY,
session_expires integer NOT NULL,
session_data text NOT NULL,
session_ip varchar(39) NOT NULL,
user_id integer
);
Any help or insight would be much appreciated.index.php
database.php
main.php
sessions.php