Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Session handler base.

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

Defines 1 class

handler:: (5 methods):
  start()
  write_close()
  abort()
  set_requires_write_lock()
  requires_write_lock()


Class: handler  - X-Ref

Session handler base.

start()   X-Ref
Start the session.

return: bool success

write_close()   X-Ref
Write the session and release lock. If the session was not intentionally opened
with a write lock, then we will abort the session instead if able.


abort()   X-Ref
Release lock on the session without writing it.
May not be possible in older versions of PHP. If so, session may be written anyway
so that any locks are released.


set_requires_write_lock($requireswritelock)   X-Ref
This is called after init() and before start() to indicate whether the session
opened should be writable or not. This is intentionally captured even if your
handler doesn't support non-locking sessions, so that behavior (upon session close)
matches closely between handlers.

param: bool $requireswritelock true if needs to be open for writing

requires_write_lock()   X-Ref
Has this session been opened with a writelock? Your handler should call this during
start() if you support read-only sessions.

return: bool true if session is intended to have a write lock.