File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -453,6 +453,31 @@ File upload are available ONLY for multipart requests.
453453
454454====
455455
456+ ==== Session
457+
458+ Session parameters are available via javadoc::Context[session] or javadoc::Context[sessionOrNull]
459+ methods. HTTP Session is covered in his own <<session, chapter>>, but here is a quick look:
460+
461+ .Java
462+ [source,java,role="primary"]
463+ ----
464+ Session session = ctx.session(); // <1>
465+
466+ String attribute = ctx.session("attribute").value(); // <2>
467+
468+ ----
469+
470+ .Kotlin
471+ [source,kotlin,role="secondary"]
472+ ----
473+ val session = ctx.session() // <1>
474+
475+ val attribute = session.attribute("attribute").value() // <2>
476+ ----
477+
478+ <1> Find an existing Session or create one
479+ <2> Get a session attribute
480+
456481==== Flash
457482
458483Flash parameters are designed to transport success/error messages between requests. It is similar to
Original file line number Diff line number Diff line change @@ -238,6 +238,8 @@ include::static-files.adoc[]
238238
239239include::templates.adoc[]
240240
241+ include::session.adoc[]
242+
241243include::execution-model.adoc[]
242244
243245include::responses.adoc[]
Original file line number Diff line number Diff line change 11== Session
2+
3+ Session is accessible via
4+
5+ - javadoc::Context[sessionOrNull] : which find an existing session
6+ - javadoc::Context[session] : which find an existing session or create a new one
7+
8+ Sessions have a lot of uses cases but the most commons are: authentication, storing information
9+ about current user, etc.
10+
11+ A session attribute must be a String or a primitive. The session doesn't allow storing of arbitrary
12+ objects. It's intended as a simple mechanism to store basic data (not an object graph).
13+
14+ Jooby provides two javadoc::SessionStore[] implementation:
15+
16+ - In-Memory sessions - which you should combine with an a sticky sessions proxy if you plan to run multiple instances.
17+ - Cookie sessions signed with a secret key
18+
19+ === Working with Sessions
20+
21+
You can’t perform that action at this time.
0 commit comments