For using lack-middleware-session in CLOG
(clog:initialize 'SOME-HANDLER
:lack-middleware-list `(,lack.middleware.session:*lack-middleware-session*
,clog-lack-session:*middleware*))
Then, you can use (clog-lack-session:current-session clog-obj)
to get the server-side session as a hash-table
In your CLOG app, you can gethash to retrieve/setf server-side session based current user data
(gethash :current-user
(clog-lack-session:current-session clog-obj))
With the following code, when a user visit the root path "/"
without corresponding current user data, the user can only see "I'm a static front page."
(clog:initialize nil
:lack-middleware-list `(,lack.middleware.session:*lack-middleware-session*
,clog-lack-session:*middleware*
,(lambda (app)
(lambda (env)
(cond ((and (string= (getf env
:path-info)
"/")
(null (gethash :current-user
(getf env
:lack.session))))
`(200 (:content-type "text/plain")
("I'm a static front page.")))
(t
(funcall app env)))))))
$ ros install shakatoday/clog-lack-session
$ cd PATH-TO-YOUR-QUICKLISP-LOCAL-PROJECT
$ git clone https://github.com/shakatoday/clog-lack-session.git
Then quicklisp can find it.
It currently uses document.cookie
API. You can't turn on HttpOnly
for cookie.
I'll find another way so it won't call document.cookie
in the future.
- Shaka Chen ([email protected])
Copyright (c) 2022 Shaka Chen ([email protected])
Licensed under the BSD 3-Clause License.