aboutsummaryrefslogtreecommitdiffstats
path: root/config/session.ts
diff options
context:
space:
mode:
Diffstat (limited to 'config/session.ts')
-rw-r--r--config/session.ts116
1 files changed, 116 insertions, 0 deletions
diff --git a/config/session.ts b/config/session.ts
new file mode 100644
index 0000000..fbf8c7c
--- /dev/null
+++ b/config/session.ts
@@ -0,0 +1,116 @@
1/**
2 * Config source: https://git.io/JeYHp
3 *
4 * Feel free to let us know via PR, if you find something broken in this config
5 * file.
6 */
7
8import Env from '@ioc:Adonis/Core/Env';
9import Application from '@ioc:Adonis/Core/Application';
10import { sessionConfig } from '@adonisjs/session/build/config';
11
12export default sessionConfig({
13 /*
14 |--------------------------------------------------------------------------
15 | Enable/Disable sessions
16 |--------------------------------------------------------------------------
17 |
18 | Setting the following property to "false" will disable the session for the
19 | entire application
20 |
21 */
22 enabled: true,
23
24 /*
25 |--------------------------------------------------------------------------
26 | Driver
27 |--------------------------------------------------------------------------
28 |
29 | The session driver to use. You can choose between one of the following
30 | drivers.
31 |
32 | - cookie (Uses signed cookies to store session values)
33 | - file (Uses filesystem to store session values)
34 | - redis (Uses redis. Make sure to install "@adonisjs/redis" as well)
35 |
36 | Note: Switching drivers will make existing sessions invalid.
37 |
38 */
39 driver: Env.get('SESSION_DRIVER', 'cookie'),
40
41 /*
42 |--------------------------------------------------------------------------
43 | Cookie name
44 |--------------------------------------------------------------------------
45 |
46 | The name of the cookie that will hold the session id.
47 |
48 */
49 cookieName: 'adonis-session',
50
51 /*
52 |--------------------------------------------------------------------------
53 | Clear session when browser closes
54 |--------------------------------------------------------------------------
55 |
56 | Whether or not you want to destroy the session when browser closes. Setting
57 | this value to `true` will ignore the `age`.
58 |
59 */
60 clearWithBrowser: true,
61
62 /*
63 |--------------------------------------------------------------------------
64 | Session age
65 |--------------------------------------------------------------------------
66 |
67 | The duration for which session stays active after no activity. A new HTTP
68 | request to the server is considered as activity.
69 |
70 | The value can be a number in milliseconds or a string that must be valid
71 | as per https://npmjs.org/package/ms package.
72 |
73 | Example: `2 days`, `2.5 hrs`, `1y`, `5s` and so on.
74 |
75 */
76 age: '2h',
77
78 /*
79 |--------------------------------------------------------------------------
80 | Cookie values
81 |--------------------------------------------------------------------------
82 |
83 | The cookie settings are used to setup the session id cookie and also the
84 | driver will use the same values.
85 |
86 */
87 cookie: {
88 path: '/',
89 httpOnly: true,
90 sameSite: false,
91 },
92
93 /*
94 |--------------------------------------------------------------------------
95 | Configuration for the file driver
96 |--------------------------------------------------------------------------
97 |
98 | The file driver needs absolute path to the directory in which sessions
99 | must be stored.
100 |
101 */
102 file: {
103 location: Application.tmpPath('sessions'),
104 },
105
106 /*
107 |--------------------------------------------------------------------------
108 | Redis driver
109 |--------------------------------------------------------------------------
110 |
111 | The redis connection you want session driver to use. The same connection
112 | must be defined inside `config/redis.ts` file as well.
113 |
114 */
115 redisConnection: 'local',
116});