Skip to content

Commit b5509a0

Browse files
committed
Doc: Start of Session doc
1 parent 044a001 commit b5509a0

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

docs/asciidoc/context.adoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff 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

458483
Flash parameters are designed to transport success/error messages between requests. It is similar to

docs/asciidoc/index.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ include::static-files.adoc[]
238238

239239
include::templates.adoc[]
240240

241+
include::session.adoc[]
242+
241243
include::execution-model.adoc[]
242244

243245
include::responses.adoc[]

docs/asciidoc/session.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
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+

0 commit comments

Comments
 (0)