From 8fd92701e9074b79a72982809a6a87f8e943399a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 2 Mar 2006 09:20:02 +0100 Subject: [PATCH] update schema, new option: DATABASE_BACKED_SESSIONS --- config.php-dist | 4 ++++ schema/ttrss_schema_mysql.sql | 3 +-- schema/ttrss_schema_pgsql.sql | 8 +++----- schema/upgrade-1.1.3-1.1.4-mysql.sql | 3 +-- schema/upgrade-1.1.3-1.1.4-pgsql.sql | 7 +++---- sessions.php | 6 +++++- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/config.php-dist b/config.php-dist index 047de65c..a17c352e 100644 --- a/config.php-dist +++ b/config.php-dist @@ -100,5 +100,9 @@ define('DAEMON_SLEEP_INTERVAL', 120); // Interval between update daemon update runs + define('DATABASE_BACKED_SESSIONS', true); + // Store session information in a database (recommended) + // Uses default PHP session storing mechanism if disabled + // vim:ft=php ?> diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index 5032334c..540fc0f2 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -256,8 +256,7 @@ create table ttrss_scheduled_updates (id integer not null primary key auto_incre foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE, foreign key (feed_id) references ttrss_feeds(id) ON DELETE CASCADE) TYPE=InnoDB; -create table ttrss_sessions (int_id integer not null primary key auto_increment, - id varchar(300) unique not null, +create table ttrss_sessions (id varchar(300) unique not null primary key, data text, expire integer not null, index (id), diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index ec98bbb2..c6bc4521 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -231,12 +231,10 @@ create table ttrss_scheduled_updates (id serial not null primary key, feed_id integer default null references ttrss_feeds(id) ON DELETE CASCADE, entered timestamp not null default NOW()); -create table ttrss_sessions (int_id serial not null primary key, - id varchar(300) unique not null, - data text, - expire integer not null); +create table ttrss_sessions (id varchar(300) unique not null primary key, + data text, + expire integer not null); -create index ttrss_sessions_id_index on ttrss_sessions(id); create index ttrss_sessions_expire_index on ttrss_sessions(expire); commit; diff --git a/schema/upgrade-1.1.3-1.1.4-mysql.sql b/schema/upgrade-1.1.3-1.1.4-mysql.sql index f2e9bd16..32b45e89 100644 --- a/schema/upgrade-1.1.3-1.1.4-mysql.sql +++ b/schema/upgrade-1.1.3-1.1.4-mysql.sql @@ -5,8 +5,7 @@ update ttrss_entries set author = ''; alter table ttrss_entries change author author varchar(250) not null; alter table ttrss_entries alter column author set default ''; -create table ttrss_sessions (int_id integer not null primary key auto_increment, - id varchar(300) unique not null, +create table ttrss_sessions (id varchar(300) unique not null primary key, data text, expire integer not null, index (id), diff --git a/schema/upgrade-1.1.3-1.1.4-pgsql.sql b/schema/upgrade-1.1.3-1.1.4-pgsql.sql index 6a0f46b5..d1d310f3 100644 --- a/schema/upgrade-1.1.3-1.1.4-pgsql.sql +++ b/schema/upgrade-1.1.3-1.1.4-pgsql.sql @@ -7,10 +7,9 @@ update ttrss_entries set author = ''; alter table ttrss_entries alter column author set not null; alter table ttrss_entries alter column author set default ''; -create table ttrss_sessions (int_id serial not null primary key, - id varchar(300) unique not null, - data text, - expire integer not null); +create table ttrss_sessions (id varchar(300) unique not null primary key, + data text, + expire integer not null); create index ttrss_sessions_id_index on ttrss_sessions(id); create index ttrss_sessions_expire_index on ttrss_sessions(expire); diff --git a/sessions.php b/sessions.php index dddab501..54b862a3 100644 --- a/sessions.php +++ b/sessions.php @@ -7,6 +7,7 @@ $session_expire = 600; ini_set("session.gc_probability", 50); + ini_set("session.name", "ttrss_sid"); function open ($s, $n) { @@ -87,6 +88,9 @@ db_query($session_connection, $query); } - session_set_save_handler ("open", "close", "read", "write", "destroy", "gc"); + if (DATABASE_BACKED_SESSIONS) { + session_set_save_handler ("open", "close", "read", "write", "destroy", "gc"); + } + session_start(); ?>