MCPcopy Create free account
hub / github.com/adonisjs/session / SessionClient

Class SessionClient

src/client.ts:26–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24 * await client.commit()
25 */
26export class SessionClient {
27 /**
28 * Internal data store for session values
29 */
30 #valuesStore = new ValuesStore({})
31
32 /**
33 * Internal store for flash messages
34 */
35 #flashMessagesStore = new ValuesStore({})
36
37 /**
38 * The session store contract for reading and writing session data
39 */
40 #store: SessionStoreContract
41
42 /**
43 * Session key used for storing flash messages
44 */
45 flashKey = '__flash__'
46
47 /**
48 * Session ID to use when no explicit session id is defined
49 */
50 sessionId = randomUUID()
51
52 /**
53 * Creates a new session client
54 *
55 * @param store - Session store contract implementation
56 */
57 constructor(store: SessionStoreContract) {
58 this.#store = store
59 }
60
61 /**
62 * Merges session data with existing values
63 *
64 * @param values - Session data to merge
65 *
66 * @example
67 * client.merge({ userId: 123, theme: 'dark' })
68 */
69 merge(values: SessionData) {
70 this.#valuesStore.merge(values)
71 return this
72 }
73
74 /**
75 * Merges flash messages with existing flash data
76 *
77 * @param values - Flash message data to merge
78 *
79 * @example
80 * client.flash({ success: 'Operation completed', info: 'Check your email' })
81 */
82 flash(values: SessionData) {
83 this.#flashMessagesStore.merge(values)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected