Skip to content

Commit c5c3915

Browse files
committed
session, log-in+++
1 parent 7ce7330 commit c5c3915

File tree

8 files changed

+460
-22
lines changed

8 files changed

+460
-22
lines changed

content/building-blocks/building-binaries.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ So, the recipe to run our project from sources can look like this (you can find
3030
3131
(in-package :myproject)
3232
(handler-case
33-
;; The START function starts the web server.
34-
(myproject::start :port (ignore-errors (parse-integer (uiop:getenv "PROJECT_PORT"))))
33+
(myproject::start-app :port (ignore-errors (parse-integer (uiop:getenv "PROJECT_PORT"))))
3534
(error (c)
3635
(format *error-output* "~&An error occured: ~a~&" c)
3736
(uiop:quit 1)))

content/building-blocks/database.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,12 @@ To set them, look at your DB driver how to run a raw SQL query.
254254
With `cl-dbi`, this would be `dbi:do-sql`:
255255

256256
```lisp
257-
(dbi:do-sql *connection*
258-
"PRAGMA auto_vacuum;")
257+
(dbi:do-sql *connection* "PRAGMA cache_size = -20000;")
259258
```
260259

261260
Here's a nice list of pragmas useful for web development:
262261

263-
- [https://dev.to/briandouglasie/sensible-sqlite-defaults-5ei7](https://dev.to/briandouglasie/sensible-sqlite-defaults-5ei7)
262+
- [https://briandouglas.ie/sqlite-defaults/](https://briandouglas.ie/sqlite-defaults/)
264263

265264

266265
## References

content/building-blocks/errors-interactivity.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Hunchentoot defines condition classes:
6060
- `hunchentoot-warning`, the superclass for all warnings
6161
- `hunchentoot-error`, the superclass for errors
6262
- `parameter-error`
63+
- `bad-request`
6364

6465
See the (light) documentation: [https://edicl.github.io/hunchentoot/#conditions](https://edicl.github.io/hunchentoot/#conditions).
6566

content/building-blocks/session.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,25 @@
22
title = "Sessions"
33
weight = 35
44
+++
5+
6+
When a web client (a user's browser) connects to your app, you can
7+
start a session with it, and store data, the time of the session.
8+
9+
Hunchentoot uses cookies to store the session ID, and if not possible
10+
it rewrites URLs. So, at every subsequent request by this web client,
11+
you can check if there is a session data.
12+
13+
You can store any Lisp object in a web session. You only have to:
14+
15+
- start a session with `(hunchentoot:start-session)`
16+
- for example, when a user logs in successfully
17+
- store an object with `(setf (hunchentoot:session-value 'key) val)`
18+
- for example, store the username at the log-in
19+
- and get the object with `(hunchentoot:session-value 'key)`.
20+
- for example, in any route where you want to check that a user is logged in. If you don't find a session key you want, you would redirect to the login page.
21+
22+
See our example in the next section about log-in.
23+
24+
## References
25+
26+
- [https://common-lisp-libraries.readthedocs.io/hunchentoot/#8-session](https://common-lisp-libraries.readthedocs.io/hunchentoot/#8-session)

0 commit comments

Comments
 (0)