Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core\session\utility\cookie_helper Class Reference

Static Public Member Functions

static add_attributes_to_cookie_response_header (string $cookiename, array $attributes)
 Make sure the given attributes are set on the Set-Cookie response header identified by name=$cookiename.
 
static cookie_response_headers_add_attributes (array $headerstrings, array $cookiestomatch, array $attributes, bool $casesensitive=false)
 Given a list of HTTP header strings, return a list of HTTP header strings where the matched 'Set-Cookie' headers have been updated with the attributes defined in $attribute - an array of strings.
 
static expire_moodlesession ()
 Forces the expiry of the MoodleSession cookie.
 

Member Function Documentation

◆ add_attributes_to_cookie_response_header()

static core\session\utility\cookie_helper::add_attributes_to_cookie_response_header ( string $cookiename,
array $attributes )
static

Make sure the given attributes are set on the Set-Cookie response header identified by name=$cookiename.

This function only affects Set-Cookie headers and modifies the headers directly with the required changes, if any.

Parameters
string$cookienamethe cookie name.
array$attributesthe attributes to set/ensure are set.
Return values
void

◆ cookie_response_headers_add_attributes()

static core\session\utility\cookie_helper::cookie_response_headers_add_attributes ( array $headerstrings,
array $cookiestomatch,
array $attributes,
bool $casesensitive = false )
static

Given a list of HTTP header strings, return a list of HTTP header strings where the matched 'Set-Cookie' headers have been updated with the attributes defined in $attribute - an array of strings.

This method does not verify whether a given attribute is valid or not. It blindly sets it and returns the header strings. It's up to calling code to determine whether an attribute makes sense or not.

Parameters
array$headerstringsthe array of header strings.
array$cookiestomatchthe array of cookie names to match.
array$attributesthe attributes to set on each matched 'Set-Cookie' header.
bool$casesensitivewhether to match the attribute in a case-sensitive way.
Return values
arraythe updated array of header strings.

◆ expire_moodlesession()

static core\session\utility\cookie_helper::expire_moodlesession ( )
static

Forces the expiry of the MoodleSession cookie.

This is useful to force a new Set-Cookie header on the next redirect.

Return values
void

The documentation for this class was generated from the following file: