Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Database based session handler.

Copyright: 2013 Petr Skoda {@link http://skodak.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 305 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

database:: (11 methods):
  __construct()
  init()
  session_exists()
  kill_all_sessions()
  kill_session()
  handler_open()
  handler_close()
  handler_read()
  handler_write()
  handler_destroy()
  handler_gc()


Class: database  - X-Ref

Database based session handler.

__construct()   X-Ref
Create new instance of handler.


init()   X-Ref
Init session handler.


session_exists($sid)   X-Ref
Check the backend contains data for this session id.

Note: this is intended to be called from manager::session_exists() only.

param: string $sid
return: bool true if session found.

kill_all_sessions()   X-Ref
Kill all active sessions, the core sessions table is
purged afterwards.


kill_session($sid)   X-Ref
Kill one session, the session record is removed afterwards.

param: string $sid

handler_open($save_path, $session_name)   X-Ref
Open session handler.

{@see http://php.net/manual/en/function.session-set-save-handler.php}

param: string $save_path
param: string $session_name
return: bool success

handler_close()   X-Ref
Close session handler.

{@see http://php.net/manual/en/function.session-set-save-handler.php}

return: bool success

handler_read($sid)   X-Ref
Read session handler.

{@see http://php.net/manual/en/function.session-set-save-handler.php}

param: string $sid
return: string

handler_write($sid, $session_data)   X-Ref
Write session handler.

{@see http://php.net/manual/en/function.session-set-save-handler.php}

NOTE: Do not write to output or throw any exceptions!
Hopefully the next page is going to display nice error or it recovers...

param: string $sid
param: string $session_data
return: bool success

handler_destroy($sid)   X-Ref
Destroy session handler.

{@see http://php.net/manual/en/function.session-set-save-handler.php}

param: string $sid
return: bool success

handler_gc($ignored_maxlifetime)   X-Ref
GC session handler.

{@see http://php.net/manual/en/function.session-set-save-handler.php}

param: int $ignored_maxlifetime moodle uses special timeout rules
return: bool success