File tree 1 file changed +43
-3
lines changed
1 file changed +43
-3
lines changed Original file line number Diff line number Diff line change 1
1
# think-session-mysql
2
2
Use Mysql to store session for ThinkJS
3
3
4
- ## Create Database
5
4
5
+ ## Install
6
+
7
+ ```
8
+ npm install think-session-mysql
9
+ ```
10
+
11
+ ## How to use
12
+
13
+ config file ` src/config/adapter.js ` , add options:
14
+
15
+ ``` js
16
+ const mysqlSession = require (' think-session-mysql' );
17
+ exports .session = {
18
+ type: ' mysql' ,
19
+ common: {
20
+ cookie: {
21
+ name: ' thinkjs' ,
22
+ // maxAge: '',
23
+ // expires: '',
24
+ path: ' /' , // a string indicating the path of the cookie
25
+ // domain: '',
26
+ // secure: false,
27
+ // keys: [],
28
+ httpOnly: true ,
29
+ sameSite: false ,
30
+ signed: false ,
31
+ overwrite: false
32
+ }
33
+ },
34
+ mysql: {
35
+ handle: mysqlSession,
36
+ database: ' think_test' ,
37
+ prefix: ' think_' ,
38
+ host: ' 127.0.0.1' ,
39
+ port: ' 3306' ,
40
+ user: ' root' ,
41
+ password: ' '
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Create Database
47
+ ` think_ ` is the prefix in ` adapter.js `
6
48
```
7
49
DROP TABLE IF EXISTS `think_session`;
8
50
CREATE TABLE `think_session` (
@@ -15,5 +57,3 @@ Use Mysql to store session for ThinkJS
15
57
KEY `expire` (`expire`)
16
58
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17
59
```
18
-
19
- ` think_ ` is the prefix in ` db.config `
You can’t perform that action at this time.
0 commit comments