Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added ability to store sessions in db

  • Loading branch information...
commit dabd3cab3c6996479520921aae44b19741203b21 1 parent f64c1c3
@ThomasHintz authored
Showing with 26 additions and 0 deletions.
  1. +25 −0 sessions.scm
  2. +1 −0  setup.scm
View
25 sessions.scm
@@ -0,0 +1,25 @@
+(use http-session)
+
+(define (session-item->list session-item)
+ (list (session-item-expiration session-item)
+ (session-item-ip session-item)
+ (session-item-bindings session-item)
+ (session-item-finalizer session-item)))
+
+(define (list->session-item l)
+ (apply make-session-item l))
+
+(session-storage-set!
+ (lambda (sid session-item)
+ (db:store (session-item->list session-item) "sessions" sid)))
+
+(session-storage-ref
+ (lambda (sid)
+ (let ((r (db:read "sessions" sid)))
+ (if (equal? r 'not-found)
+ #f
+ (list->session-item r)))))
+
+(session-storage-delete!
+ (lambda (sid)
+ (db:delete "sessions" sid)))
View
1  setup.scm
@@ -15,5 +15,6 @@
(load "rest.scm")
(load "demo-data.scm")
(load "sections.scm")
+(load "sessions.scm")
(load "keep-the-records.scm")
Please sign in to comment.
Something went wrong with that request. Please try again.