Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ability to store sessions in db
- Loading branch information
1 parent
f64c1c3
commit dabd3ca
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters