summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-06-29 12:47:10 +0300
committerAndrew Dolgov <[email protected]>2017-06-29 12:47:10 +0300
commitf25abeb922eb5359d83fdf9068eb8d1a616fffbd (patch)
tree70f5c9da639a99b31e86b9d1fa0965aeaada844e
parent3099d2d5f8c4a2a89c71a773d0541849b31633ef (diff)
default to file-based session storage
-rw-r--r--.gitignore1
-rw-r--r--config.php-dist2
-rw-r--r--index.php4
-rw-r--r--sessions.php12
-rw-r--r--sessions/.empty0
5 files changed, 15 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index d416967..c7fa6b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
config.php
db/scratch.db
+sessions/sess*
diff --git a/config.php-dist b/config.php-dist
index 3404f34..c9d9083 100644
--- a/config.php-dist
+++ b/config.php-dist
@@ -9,3 +9,5 @@
define('DICT_CLIENT', '/usr/bin/dict');
define('DICT_SERVER', 'localhost');
+ define('SQLITE_SESSION_STORE', false);
+ // store sessions in scratch.db (not recommended, slow)
diff --git a/index.php b/index.php
index 94ed294..5260b1d 100644
--- a/index.php
+++ b/index.php
@@ -3,6 +3,10 @@
die("Please copy config.php-dist to config.php and edit it.");
}
+ if (!is_writable("sessions")) {
+ die("sessions/ directory is not writable.");
+ }
+
if (isset($_SERVER["PHP_AUTH_USER"])) {
die("HTTP Authentication is no longer supported, please see migration notes in git.");
}
diff --git a/sessions.php b/sessions.php
index 9a90ad4..82a90c2 100644
--- a/sessions.php
+++ b/sessions.php
@@ -57,12 +57,16 @@
return true;
}
- session_set_save_handler("s_open",
- "s_close", "s_read", "s_write",
- "s_destroy", "s_gc");
+
+ if (defined('SQLITE_SESSION_STORE') && SQLITE_SESSION_STORE) {
+ session_set_save_handler("s_open",
+ "s_close", "s_read", "s_write",
+ "s_destroy", "s_gc");
+ } else {
+ session_save_path(__DIR__ . "/sessions");
+ }
register_shutdown_function('session_write_close');
session_start();
-
?>
diff --git a/sessions/.empty b/sessions/.empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/sessions/.empty