|
MediaWiki master
|
Manages data for an authenticated session. More...
Inherits Countable, Iterator, and ArrayAccess.

Public Member Functions | |
| __construct (SessionBackend $backend, $index, LoggerInterface $logger) | |
| __destruct () | |
| allowSecuritySensitiveOperationIfCannotReauthenticate () | |
| Whether security-sensitive operations should be allowed at all. | |
| canSetUser () | |
| Indicate whether the session user info can be changed. | |
| clear () | |
| Delete all session data and clear the user (if possible) | |
| delaySave () | |
| Delay automatic saving while multiple updates are being made. | |
| exists ( $key) | |
| Test if a value exists in the session. | |
| get ( $key, $default=null) | |
| Fetch a value from the session. | |
| getAllowedUserRights () | |
| getId () | |
| Returns the session ID. | |
| getLoggedOutTimestamp () | |
| Fetch the "logged out" timestamp. | |
| getProvider () | |
| Fetch the SessionProvider for this session. | |
| getProviderMetadata () | |
| Fetch provider metadata. | |
| getRequest () | |
| Return the request associated with this session. | |
| getRestrictions () | |
| getSecret ( $key, $default=null) | |
| Fetch a value from the session that was set with self::setSecret() | |
| getSessionId () | |
| Returns the SessionId object. | |
| getToken ( $salt='', $key='default') | |
| Fetch a CSRF token from the session. | |
| getUser () | |
| Return the authenticated user for this session. | |
| hasToken (string $key='default') | |
| Check if a CSRF token is set for the session. | |
| isPersistent () | |
| Indicate whether this session is persisted across requests. | |
| persist () | |
| Make this session persisted across requests. | |
| remove ( $key) | |
| renew () | |
| resetAllTokens () | |
| Remove all CSRF tokens from the session. | |
| resetId () | |
| Changes the session ID. | |
| resetToken ( $key='default') | |
| Remove a CSRF token from the session. | |
| save () | |
| This will update the backend data and might re-persist the session if needed. | |
| sessionWithRequest (WebRequest $request) | |
| Fetch a copy of this session attached to an alternative WebRequest. | |
| set ( $key, $value) | |
| setForceHTTPS ( $force) | |
| Set the value of the forceHTTPS cookie. | |
| setLoggedOutTimestamp ( $ts) | |
| setRememberUser ( $remember) | |
| Set whether the user should be remembered independently of the session ID. | |
| setSecret ( $key, $value) | |
| Set a value in the session, encrypted. | |
| setUser ( $user) | |
| Set a new user for this session. | |
| shouldForceHTTPS () | |
| Get the expected value of the forceHTTPS cookie. | |
| shouldRememberUser () | |
| Indicate whether the user should be remembered independently of the session ID. | |
| suggestLoginUsername () | |
| unpersist () | |
| Make this session not be persisted across requests. | |
Interface methods | |
| count () | |
| current () | |
| key () | |
| next () | |
| rewind () | |
| valid () | |
| offsetExists ( $offset) | |
| & | offsetGet ( $offset) |
| offsetSet ( $offset, $value) | |
| offsetUnset ( $offset) | |
Manages data for an authenticated session.
A Session represents the fact that the current HTTP request is part of a session. There are two broad types of Sessions, based on whether they return true or false from self::canSetUser():
The Session object also serves as a replacement for PHP's $_SESSION, managing access to per-session data.
Definition at line 38 of file Session.php.
| MediaWiki\Session\Session::__construct | ( | SessionBackend | $backend, |
| $index, | |||
| LoggerInterface | $logger ) |
| SessionBackend | $backend | |
| int | $index | |
| LoggerInterface | $logger |
Definition at line 58 of file Session.php.
| MediaWiki\Session\Session::__destruct | ( | ) |
Definition at line 64 of file Session.php.
| MediaWiki\Session\Session::allowSecuritySensitiveOperationIfCannotReauthenticate | ( | ) |
Whether security-sensitive operations should be allowed at all.
Definition at line 198 of file Session.php.
| MediaWiki\Session\Session::canSetUser | ( | ) |
Indicate whether the session user info can be changed.
Definition at line 188 of file Session.php.
| MediaWiki\Session\Session::clear | ( | ) |
Delete all session data and clear the user (if possible)
Definition at line 277 of file Session.php.
| MediaWiki\Session\Session::count | ( | ) |
Definition at line 599 of file Session.php.
| MediaWiki\Session\Session::current | ( | ) |
Definition at line 606 of file Session.php.
| MediaWiki\Session\Session::delaySave | ( | ) |
Delay automatic saving while multiple updates are being made.
Calls to save() or clear() will not be delayed.
Definition at line 581 of file Session.php.
| MediaWiki\Session\Session::exists | ( | $key | ) |
Test if a value exists in the session.
| string | int | $key |
Definition at line 330 of file Session.php.
| MediaWiki\Session\Session::get | ( | $key, | |
| $default = null ) |
Fetch a value from the session.
| string | int | $key | |
| mixed | null | $default | Returned if $this->exists( $key ) would be false |
Definition at line 317 of file Session.php.
Referenced by MediaWiki\User\TempUser\TempUserCreator\acquireAndStashName().
| MediaWiki\Session\Session::getAllowedUserRights | ( | ) |
Definition at line 172 of file Session.php.
| MediaWiki\Session\Session::getId | ( | ) |
| MediaWiki\Session\Session::getLoggedOutTimestamp | ( | ) |
| MediaWiki\Session\Session::getProvider | ( | ) |
Fetch the SessionProvider for this session.
Definition at line 97 of file Session.php.
| MediaWiki\Session\Session::getProviderMetadata | ( | ) |
Fetch provider metadata.
Definition at line 270 of file Session.php.
| MediaWiki\Session\Session::getRequest | ( | ) |
Return the request associated with this session.
Definition at line 157 of file Session.php.
Referenced by MediaWiki\User\TempUser\TempUserCreator\acquireAndStashName().
| MediaWiki\Session\Session::getRestrictions | ( | ) |
Definition at line 180 of file Session.php.
| MediaWiki\Session\Session::getSecret | ( | $key, | |
| $default = null ) |
Fetch a value from the session that was set with self::setSecret()
| string | int | $key | |
| mixed | null | $default | Returned if $this->exists( $key ) would be false or decryption fails |
Definition at line 524 of file Session.php.
| MediaWiki\Session\Session::getSessionId | ( | ) |
Returns the SessionId object.
Definition at line 81 of file Session.php.
Referenced by MediaWiki\Request\FauxRequest\__construct().
| MediaWiki\Session\Session::getToken | ( | $salt = '', | |
| $key = 'default' ) |
Fetch a CSRF token from the session.
Note that this does not persist the session, which you'll probably want to do if you want the token to actually be useful.
| string | string[] | $salt | Token salt |
| string | $key | Token key |
Definition at line 383 of file Session.php.
Referenced by MediaWiki\Auth\ElevatedSecurityAuthenticationRequest\create().
| MediaWiki\Session\Session::getUser | ( | ) |
Return the authenticated user for this session.
Definition at line 164 of file Session.php.
Referenced by MediaWiki\Auth\ElevatedSecurityAuthenticationRequest\create().
| MediaWiki\Session\Session::hasToken | ( | string | $key = 'default' | ) |
Check if a CSRF token is set for the session.
| string | $key | Token key |
Definition at line 365 of file Session.php.
| MediaWiki\Session\Session::isPersistent | ( | ) |
Indicate whether this session is persisted across requests.
For example, if cookies are set.
Definition at line 108 of file Session.php.
| MediaWiki\Session\Session::key | ( | ) |
Definition at line 613 of file Session.php.
| MediaWiki\Session\Session::next | ( | ) |
Definition at line 619 of file Session.php.
| MediaWiki\Session\Session::offsetExists | ( | $offset | ) |
Definition at line 641 of file Session.php.
| & MediaWiki\Session\Session::offsetGet | ( | $offset | ) |
Definition at line 655 of file Session.php.
| MediaWiki\Session\Session::offsetSet | ( | $offset, | |
| $value ) |
Definition at line 665 of file Session.php.
| MediaWiki\Session\Session::offsetUnset | ( | $offset | ) |
Definition at line 670 of file Session.php.
| MediaWiki\Session\Session::persist | ( | ) |
Make this session persisted across requests.
If the session is already persistent, equivalent to calling $this->renew().
Definition at line 118 of file Session.php.
Referenced by MediaWiki\Auth\ElevatedSecurityAuthenticationRequest\create().
| MediaWiki\Session\Session::remove | ( | $key | ) |
| string | int | $key |
Definition at line 350 of file Session.php.
| MediaWiki\Session\Session::renew | ( | ) |
Definition at line 292 of file Session.php.
| MediaWiki\Session\Session::resetAllTokens | ( | ) |
Remove all CSRF tokens from the session.
Definition at line 423 of file Session.php.
| MediaWiki\Session\Session::resetId | ( | ) |
Changes the session ID.
Definition at line 89 of file Session.php.
| MediaWiki\Session\Session::resetToken | ( | $key = 'default' | ) |
Remove a CSRF token from the session.
The next call to self::getToken() with $key will generate a new secret.
| string | $key | Token key |
Definition at line 411 of file Session.php.
| MediaWiki\Session\Session::rewind | ( | ) |
Definition at line 625 of file Session.php.
| MediaWiki\Session\Session::save | ( | ) |
This will update the backend data and might re-persist the session if needed.
Definition at line 589 of file Session.php.
Referenced by MediaWiki\User\TempUser\TempUserCreator\acquireAndStashName().
| MediaWiki\Session\Session::sessionWithRequest | ( | WebRequest | $request | ) |
Fetch a copy of this session attached to an alternative WebRequest.
Actions on the copy will affect this session too, and vice versa.
| WebRequest | $request | Any existing session associated with this WebRequest object will be overwritten. |
Definition at line 305 of file Session.php.
References $request.
| MediaWiki\Session\Session::set | ( | $key, | |
| $value ) |
| string | int | $key | |
| mixed | $value |
Definition at line 339 of file Session.php.
Referenced by MediaWiki\User\TempUser\TempUserCreator\acquireAndStashName().
| MediaWiki\Session\Session::setForceHTTPS | ( | $force | ) |
Set the value of the forceHTTPS cookie.
This reflects whether session cookies were sent with the Secure attribute. If $wgForceHTTPS is true, the forceHTTPS cookie is not sent, and this value is ignored.
| bool | $force |
Definition at line 243 of file Session.php.
| MediaWiki\Session\Session::setLoggedOutTimestamp | ( | $ts | ) |
| int | $ts |
Definition at line 259 of file Session.php.
| MediaWiki\Session\Session::setRememberUser | ( | $remember | ) |
Set whether the user should be remembered independently of the session ID.
| bool | $remember |
Definition at line 148 of file Session.php.
| MediaWiki\Session\Session::setSecret | ( | $key, | |
| $value ) |
Set a value in the session, encrypted.
This relies on the secrecy of $wgSecretKey (by default), or $wgSessionSecret.
| string | int | $key | |
| mixed | $value |
Definition at line 488 of file Session.php.
| MediaWiki\Session\Session::setUser | ( | $user | ) |
Set a new user for this session.
TODO: Consider changing this to a "UserIdentity" instead.
| User | $user | User to set on the session. |
Definition at line 211 of file Session.php.
| MediaWiki\Session\Session::shouldForceHTTPS | ( | ) |
Get the expected value of the forceHTTPS cookie.
This reflects whether session cookies were sent with the Secure attribute. If $wgForceHTTPS is true, the 'forceHTTPS' cookie is not sent and this value is ignored.
Definition at line 231 of file Session.php.
| MediaWiki\Session\Session::shouldRememberUser | ( | ) |
Indicate whether the user should be remembered independently of the session ID.
Definition at line 139 of file Session.php.
| MediaWiki\Session\Session::suggestLoginUsername | ( | ) |
Definition at line 219 of file Session.php.
| MediaWiki\Session\Session::unpersist | ( | ) |
Make this session not be persisted across requests.
This will remove persistence information (e.g. delete cookies) from the associated WebRequest(s), and delete session data in the backend. The session data will still be available via get() until the end of the request.
Definition at line 130 of file Session.php.
| MediaWiki\Session\Session::valid | ( | ) |
Definition at line 631 of file Session.php.