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.
/lib/ -> sessionlib.php (source)

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

(no description)

Copyright: 1999 onwards Martin Dougiamas {@link http://moodle.com}
Copyright: 2008, 2009 Petr Skoda {@link http://skodak.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 169 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 6 functions


Functions that are not part of a class:

sesskey()   X-Ref
Makes sure that $USER->sesskey exists, if $USER itself exists. It sets a new sesskey
if one does not already exist, but does not overwrite existing sesskeys. Returns the
sesskey string if $USER exists, or boolean false if not.

return: string

confirm_sesskey($sesskey=NULL)   X-Ref
Check the sesskey and return true of false for whether it is valid.
(You might like to imagine this function is called sesskey_is_valid().)

Every script that lets the user perform a significant action (that is,
changes data in the database) should check the sesskey before doing the action.
Depending on your code flow, you may want to use the {@link require_sesskey()}
helper function.

param: string $sesskey The sesskey value to check (optional). Normally leave this blank
return: bool whether the sesskey sent in the request matches the one stored in the session.

require_sesskey()   X-Ref
Check the session key using {@link confirm_sesskey()},
and cause a fatal error if it does not match.


is_moodle_cookie_secure()   X-Ref
Determine wether the secure flag should be set on cookies

return: bool

set_moodle_cookie($username)   X-Ref
Sets a moodle cookie with a weakly encrypted username

param: string $username to encrypt and place in a cookie, '' means delete current cookie
return: void

get_moodle_cookie()   X-Ref
Gets a moodle cookie with a weakly encrypted username

return: string username