Sessions are, in many bits of web software, used to store the details of the currently logged in user, and to provide the concept of a user being logged in and logged out. Known is no exception in this.
These sessions need to be stored, in some way, on the server. Usually this is either stored in files, or in a database.
Known currently has the ability to store sessions in the currently enabled database engine (Mysql, mongo etc), or in files. However, for various reasons (e.g. you want to use a different database engine to store sessions, or you want to implement a fancy session store), it would be useful to decouple the sessions from the database.
This pull request adds the ability to specify, in your
config.ini, a handler class implementing the
This new class can then implement a session handler which uses a different storage engine, other than just files and the current database.
The other week, I wrote about introducing SQLite support to Known.
Seemingly, I was on a role, and because a client asked me to look in to Postgres support for a separate project, I thought I’d have a crack at implementing support for Known, which I’m glad has been merged in.
This turns out to have been useful to a bunch of folk, for which I am glad.
Postgres support is still in Beta, and MySQL is still the recommended database engine, so currently installation is a bit of a manual process.
First, you need to make sure you’ve got Postgres support built in to PHP:
apt-get install php5-pgsql
Then, you need to modify your
database = 'Postgres'
dbname = 'dbname'
dbpass = 'password'
dbuser = 'username'
dbhost = 'hostname'
filesystem = 'local'
uploadpath = '/path/to/upload_directory/
Once you’ve done that, you need to install the schema, which currently needs to be done from the command line.
psql -c 'create database <dbname>;' -U <dbuser>
psql -U <dbuser> -d <dbname> -a -f schemas/postgres/postgres.sql
Assuming you got no errors, you should now be good to go!