Session: add directory_path config parameter
This commit is contained in:
parent
fe75984bc7
commit
fe19313c2f
5 changed files with 25 additions and 4 deletions
1
example/data/sessions/.gitignore
vendored
Normal file
1
example/data/sessions/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
sess_*
|
|
@ -102,8 +102,12 @@ i18n:
|
||||||
# Session
|
# Session
|
||||||
#
|
#
|
||||||
session:
|
session:
|
||||||
timeout: 1800 # Session timeout dur to inactivity (in seconds)
|
# Session timeout due to inactivity (in seconds)
|
||||||
max_duration: 43200 # Session max duration (in seconds, default : 12h)
|
timeout: 1800
|
||||||
|
# Session max duration (in seconds, default : 12h)
|
||||||
|
max_duration: 43200
|
||||||
|
# Directory path where to store PHP sessions data (optional, default: use system default)
|
||||||
|
directory_path: "${data_directory}/sessions"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Database configuration
|
# Database configuration
|
||||||
|
|
|
@ -102,8 +102,12 @@ i18n:
|
||||||
# Session
|
# Session
|
||||||
#
|
#
|
||||||
session:
|
session:
|
||||||
timeout: 1800 # Session timeout dur to inactivity (in seconds)
|
# Session timeout due to inactivity (in seconds)
|
||||||
max_duration: 43200 # Session max duration (in seconds, default : 12h)
|
timeout: 1800
|
||||||
|
# Session max duration (in seconds, default : 12h)
|
||||||
|
max_duration: 43200
|
||||||
|
# Directory path where to store PHP sessions data (optional, default: use system default)
|
||||||
|
directory_path: "${data_directory}/sessions"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Database configuration
|
# Database configuration
|
||||||
|
|
1
skel/data/sessions/.gitignore
vendored
Normal file
1
skel/data/sessions/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
sess_*
|
|
@ -30,6 +30,7 @@ class Session {
|
||||||
array(
|
array(
|
||||||
'max_duration' => 43200, // 12h
|
'max_duration' => 43200, // 12h
|
||||||
'timeout' => null,
|
'timeout' => null,
|
||||||
|
'directory_path' => null,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -38,6 +39,16 @@ class Session {
|
||||||
Config :: ini_set('session.gc_maxlifetime', strval(self :: $max_duration));
|
Config :: ini_set('session.gc_maxlifetime', strval(self :: $max_duration));
|
||||||
Config :: ini_set('session.cookie_lifetime', strval(self :: $max_duration));
|
Config :: ini_set('session.cookie_lifetime', strval(self :: $max_duration));
|
||||||
|
|
||||||
|
// Set custom session directory (if configured)
|
||||||
|
$directory_path = App::get('session.directory_path', null, 'string');
|
||||||
|
if ($directory_path) {
|
||||||
|
Log :: trace('Set session directory path as "%s"', $directory_path);
|
||||||
|
if (!session_save_path($directory_path)) {
|
||||||
|
Log :: warning('Fail to set session directory path as "%s"', $directory_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log :: debug('Use session directory "%s"', session_save_path());
|
||||||
|
|
||||||
// Start session
|
// Start session
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue