Session handling: Difference between revisions
Line 26: | Line 26: | ||
$CFG->session_memcached_prefix = 'memc.sess.key.'; | $CFG->session_memcached_prefix = 'memc.sess.key.'; | ||
$CFG->session_memcached_acquire_lock_timeout = 120; | $CFG->session_memcached_acquire_lock_timeout = 120; | ||
$CFG->session_memcached_lock_expire = 7200; // Ignored if memcached extension <= 2.1.0 | |||
</code> | </code> | ||
Line 31: | Line 32: | ||
* Make sure the memcached server has enough memory. | * Make sure the memcached server has enough memory. | ||
* Use different prefix when storing sessions from multiple Moodles in one server. | * Use different prefix when storing sessions from multiple Moodles in one server. | ||
* | * I memcached extension <= 2.1.0 the locking works differently from other drivers, the lock is expired/released at the end of timeout - see MDL-42485. | ||
===Files=== | ===Files=== |
Revision as of 15:06, 27 October 2013
An administrator can change the following settings in Settings > Site administration > Server > Session Handling.
Timeout
Once someone logs in to your Moodle server, the server starts a session. The session data allows the server to track users as they access different pages. If users don't load a new page during the amount of time set here, Moodle will end their session and log them out.
Be sure this time frame is long enough to cover the longest test your teachers may offer. If a student is logged out while they are taking a test, their responses to the test questions may be lost.
Cookie prefix
Most of the time, you can leave this blank, unless you are running more than one Moodle site on the same server. In this case, you will want to customize the name of the cookie each Moodle site uses to track the session. This enables you to be logged into more than one Moodle site at the same time.
Note: If you change "Cookie prefix" or "Cookie path" you will need to login again as the changes take effect immediately.
Session drivers
User sessions may be stored in different backends. Session drivers can be configured only in config.php file - see examples in config-dist.php file.
Memcache
Memcached session driver is the fastest driver, it requires external memcached server and PHP extension. Server cluster nodes must use shared session backend.
Configuration options in config.php:
$CFG->session_handler_class = '\core\session\memcached';
$CFG->session_memcached_save_path = '127.0.0.1:11211';
$CFG->session_memcached_prefix = 'memc.sess.key.';
$CFG->session_memcached_acquire_lock_timeout = 120;
$CFG->session_memcached_lock_expire = 7200; // Ignored if memcached extension <= 2.1.0
Notes:
- Make sure the memcached server has enough memory.
- Use different prefix when storing sessions from multiple Moodles in one server.
- I memcached extension <= 2.1.0 the locking works differently from other drivers, the lock is expired/released at the end of timeout - see MDL-42485.
Files
This driver is used by default in new installation.
Configuration options in config.php:
$CFG->session_handler_class = '\core\session\file';
$CFG->session_file_save_path = $CFG->dataroot.'/sessions';
Notes:
- File based session require file system that supports file locking.
Database
This driver was used by default in Moodle 2.0-2.5
$CFG->session_handler_class = '\core\session\database';
$CFG->session_database_acquire_lock_timeout = 120;
Notes:
- DB sessions are not compatible with MyISAM database engine.