class session_support

internal  
 

Session support wrapper for Moodle's session management.

Methods

static bool
confirm_sesskey(string|null $sesskey = null)

Confirms that the current sesskey is valid.

static void
require_sesskey()

Ensures that the current sesskey is valid.

static string
sesskey()

Retrieves the current sesskey.

static void
destroy_user_sessions(int $userid, string $except = '')

Destroys all active sessions for a specific user.

static void
set_user(stdClass $user)

Sets the current user in the session.

static string|null
get_wants_url()

Retrieves the URL the user was trying to access before login.

static void
unset_wants_url()

Removes the wantsurl from the session.

static string
get_id()

Retrieves the current PHP session ID.

Details

at line 38
static bool confirm_sesskey(string|null $sesskey = null)

Confirms that the current sesskey is valid.

Parameters

string|null $sesskey

sesskey to validate (null for current request)

Return Value

bool

True if valid, false otherwise

at line 48
static void require_sesskey()

Ensures that the current sesskey is valid.

Return Value

void

Exceptions

moodle_exception

at line 58
static string sesskey()

Retrieves the current sesskey.

Return Value

string sesskey

at line 69
static void destroy_user_sessions(int $userid, string $except = '')

Destroys all active sessions for a specific user.

Parameters

int $userid

User ID

string $except

current session ID to keep

Return Value

void

at line 79
static void set_user(stdClass $user)

Sets the current user in the session.

Parameters

stdClass $user

User object

Return Value

void

at line 89
static string|null get_wants_url()

Retrieves the URL the user was trying to access before login.

Return Value

string|null

the intended URL or null if not set

at line 99
static void unset_wants_url()

Removes the wantsurl from the session.

Return Value

void

at line 110
static string get_id()

Retrieves the current PHP session ID.

Return Value

string

Session ID