Session persistence

This commit is contained in:
2019-10-08 23:24:25 +02:00
parent c996881547
commit 9b7324e20a
20 changed files with 258 additions and 50 deletions

1
sql/sessions/all.sql Normal file
View File

@@ -0,0 +1 @@
SELECT "sid", "session" FROM "sessions";

1
sql/sessions/clear.sql Normal file
View File

@@ -0,0 +1 @@
TRUNCATE "sessions";

1
sql/sessions/destroy.sql Normal file
View File

@@ -0,0 +1 @@
DELETE FROM "sessions" WHERE "sid" = $1;

1
sql/sessions/get.sql Normal file
View File

@@ -0,0 +1 @@
SELECT "session" FROM "sessions" WHERE "sid"=$1 AND CURRENT_TIMESTAMP < "expires_at";

1
sql/sessions/length.sql Normal file
View File

@@ -0,0 +1 @@
SELECT COUNT(*) as length FROM "sessions";

3
sql/sessions/set.sql Normal file
View File

@@ -0,0 +1,3 @@
INSERT INTO "sessions" AS s ("sid", "session", "expires_at") VALUES ($1, $2, $3)
ON CONFLICT ON CONSTRAINT "session_pkey"
DO UPDATE SET "session"=$2, "expires_at"=$3 WHERE "s"."sid"=$1;

1
sql/sessions/touch.sql Normal file
View File

@@ -0,0 +1 @@
UPDATE "sessions" SET "expires_at"=$2 WHERE "sid"=$1;