Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/sessionlib.php File Reference

Go to the source code of this file.

Data Structures

interface  moodle_session
class  emergency_session
class  session_stub
class  legacy_file_session
class  database_session

Namespaces

namespace  core

Functions

if(!defined('SESSION_ACQUIRE_LOCK_TIMEOUT')) session_get_instance ()
 session_is_legacy ()
 session_kill_all ()
 session_touch ($sid)
 session_kill ($sid)
 session_kill_user ($userid)
 session_gc ()
 sesskey ()
 confirm_sesskey ($sesskey=NULL)
 require_sesskey ()
 set_moodle_cookie ($username)
 get_moodle_cookie ()
 session_set_user ($user)
 session_is_loggedinas ()
 session_get_realuser ()
 session_loginas ($userid, $context)
 cron_setup_user ($user=NULL, $course=NULL)

Function Documentation

confirm_sesskey ( sesskey = NULL)

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 require_sesskey() helper function.

Parameters:
string$sesskeyThe sesskey value to check (optional). Normally leave this blank and this function will do required_param('sesskey', ...).
Returns:
bool whether the sesskey sent in the request matches the one stored in the session.

Definition at line 972 of file sessionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

cron_setup_user ( user = NULL,
course = NULL 
)

Sets up current user and course environment (lang, etc.) in cron. Do not use outside of cron script!

Parameters:
stdClass$userfull user object, null means default cron user (admin)
$coursefull course record, null means $SITE
Returns:
void

ignore admins timezone, language and locale - use site default instead!

Definition at line 1130 of file sessionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Gets a moodle cookie with a weakly encrypted username

Returns:
string username

Definition at line 1035 of file sessionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Check the session key using confirm_sesskey(), and cause a fatal error if it does not match.

Definition at line 990 of file sessionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Session garbage collection

  • verify timeout for all users
  • kill sessions of all deleted users
  • kill sessions of users with disabled plugins or 'nologin' plugin

NOTE: this can not work when legacy file sessions used!

kill all sessions of deleted users

kill sessions of users with disabled plugins

now get a list of time-out candidates

Definition at line 891 of file sessionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

if (!defined('SESSION_ACQUIRE_LOCK_TIMEOUT')) session_get_instance ( )

Factory method returning moodle_session object.

Returns:
moodle_session

Definition at line 39 of file sessionlib.php.

Here is the caller graph for this function:

Returns the $USER object ignoring current login-as session

Returns:
stdClass user object

Definition at line 1087 of file sessionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

returns true if legacy session used.

Returns:
bool true if legacy(==file) based session used

Definition at line 783 of file sessionlib.php.

Here is the caller graph for this function:

Is current $USER logged-in-as somebody else?

Returns:
bool

Definition at line 1079 of file sessionlib.php.

Here is the caller graph for this function:

session_kill ( sid)

Terminates one sessions, auth hooks are not executed.

Parameters:
string$sidsession id

Definition at line 843 of file sessionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Terminates all sessions, auth hooks are not executed. Useful in upgrade scripts.

Definition at line 792 of file sessionlib.php.

Here is the call graph for this function:

session_kill_user ( userid)

Terminates all sessions of one user, auth hooks are not executed. NOTE: This can not work for file based sessions!

Parameters:
int$useriduser id

Definition at line 868 of file sessionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

session_loginas ( userid,
context 
)

Login as another user - no security checks here.

Parameters:
int$userid
stdClass$context
Returns:
void

Create the new $USER object with all details and reload needed capabilities

Definition at line 1101 of file sessionlib.php.

Here is the call graph for this function:

session_set_user ( user)

Setup $USER object - called during login, loginas, etc.

Call sync_user_enrolments() manually after log-in, or log-in-as.

Parameters:
stdClass$userfull user record object
Returns:
void

Definition at line 1069 of file sessionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

session_touch ( sid)

Mark session as accessed, prevents timeouts.

Parameters:
string$sid

Definition at line 816 of file sessionlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

sesskey ( )

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.

$USER

Returns:
string

Definition at line 949 of file sessionlib.php.

Here is the call graph for this function:

set_moodle_cookie ( username)

Sets a moodle cookie with a weakly encrypted username

Parameters:
string$usernameto encrypt and place in a cookie, '' means delete current cookie
Returns:
void

Definition at line 1002 of file sessionlib.php.

Here is the call graph for this function:

 All Data Structures Namespaces Files Functions Variables Enumerations