Fix expire bug

This fixes an issue with getting sessions out of a PostgreSQL backed session table.  It also improves error handling a little bit.

I've tested it with PostgreSQL 9.3 and I ran the sqlite3 tests, which still pass, but have not had a chance to run any tests on MySQL.