/
jsession.gtw
64 lines (40 loc) · 1.82 KB
/
jsession.gtw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
~~LANG:FR@frman:classes-utiles/jsession~~
jSession is the object used by Jelix to initialize the storage engine. It is not used to read or store variables in session. **Use $_SESSION as usual** to do this task.
Configuration of the session storage is done in @@F@app/var/config/defaultconfig.ini.php@@, in a @@sessions@@ section.
===== Session name =====
You may need to change the session's name (default is PHPSESSID).
To make such a change, you can use the following configuration directive :
<code ini>
[sessions]
name = "mysession"
</code>
NB : only alpha-numeric chars are allowed.
===== File storage =====
Storing session files in default path may not be a good idea, as that path is often worldwide readable/writable, like /tmp/ for example.
To make jSession store sessions in your own defined path :
<code ini>
[sessions]
storage = "files"
files_path = "app:var/sessions/"
</code>
NB : app: and lib: keywords are converted.
===== Database storage =====
You may need to store your sessions in data, for example when you are doing load-balancing with multiple front servers. In this case, jSession uses jDao:
<code ini>
[sessions]
storage = "dao"
dao_selector = "jelix~jsession"
dao_db_profile = ""
</code>
A default dao is provided in the jelix module. The selector is @@jelix~jsession@@.
When you install your application, if the configuration is set correctly, Jelix will create a table in your SQL database. During the development, you can execute on of these SQL script to create the table: @@F@lib/jelix/core-modules/jelix/install/sql/install_jsession.schema.*@@.
Here is the table:
<code php>
CREATE TABLE IF NOT EXISTS `jsessions` (
`id` varchar(64) NOT NULL,
`creation` datetime NOT NULL,
`access` datetime NOT NULL,
`data` longblob NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
</code>