|
MediaWiki master
|
This is the actual workhorse for Session. More...
Public Member Functions | |
| __construct (SessionId $id, SessionInfo $info, SessionStore $sessionStore, LoggerInterface $logger, HookContainer $hookContainer, $lifetime) | |
| addData (array $newData) | |
| Add data to the session. | |
| canSetUser () | |
| Whether the session user info can be changed. | |
| delaySave () | |
| Delay automatic saving while multiple updates are being made. | |
| deregisterSession ( $index) | |
| Deregister a Session. | |
| dirty () | |
| Mark data as dirty. | |
| getAllowedUserRights () | |
| & | getData () |
| Fetch the session data array. | |
| getId () | |
| Return the session ID. | |
| getLoggedOutTimestamp () | |
| Fetch the "logged out" timestamp. | |
| getProvider () | |
| Fetch the SessionProvider for this session. | |
| getProviderMetadata () | |
| Fetch provider metadata. | |
| getRequest ( $index) | |
| Return the request associated with a Session. | |
| getRestrictions () | |
| getSession (WebRequest $request) | |
| Create a new Session for this backend. | |
| getSessionId () | |
| Fetch the SessionId object. | |
| getUser () | |
| Return the authenticated user for this session. | |
| isPersistent () | |
| Whether this session is persisted across requests. | |
| persist (bool $force=false) | |
| Make this session persisted across requests by calling SessionProvider::persist() and saving the session data and metadata to the session store. | |
| renew () | |
| Renew the session by re-saving all data with a new TTL. | |
| resetId () | |
| Change the session ID. | |
| save ( $closing=false) | |
| Save the session. | |
| setForceHTTPS ( $force) | |
| Set whether HTTPS should be forced. | |
| setLoggedOutTimestamp ( $ts=null) | |
| setProviderMetadata ( $metadata) | |
| setRememberUser ( $remember) | |
| Set whether the user should be remembered, independently of the session ID. | |
| setUser ( $user) | |
| Set a new User object for this session. | |
| shouldForceHTTPS () | |
| Whether HTTPS should be forced. | |
| shouldRememberUser () | |
| Whether the user should be remembered, independently of the session ID. | |
| shutdown () | |
| Shut down a session. | |
| suggestLoginUsername ( $index) | |
| unpersist () | |
| Make this session not persisted across requests. | |
This is the actual workhorse for Session.
Most code does not need to use this class, you want \MediaWiki\Session\Session. The exceptions are SessionProviders and SessionMetadata hook functions, which get an instance of this class rather than Session.
The reasons for this split are:
Definition at line 43 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::__construct | ( | SessionId | $id, |
| SessionInfo | $info, | ||
| SessionStore | $sessionStore, | ||
| LoggerInterface | $logger, | ||
| HookContainer | $hookContainer, | ||
| $lifetime ) |
| SessionId | $id | |
| SessionInfo | $info | Session info to populate from |
| SessionStore | $sessionStore | |
| LoggerInterface | $logger | |
| HookContainer | $hookContainer | |
| int | $lifetime | Session data lifetime in seconds |
Definition at line 129 of file SessionBackend.php.
References MediaWiki\Session\SessionInfo\forceHTTPS(), MediaWiki\Session\SessionStore\get(), MediaWiki\Session\SessionId\getId(), MediaWiki\Session\SessionInfo\getId(), MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Session\SessionInfo\getPriority(), MediaWiki\Session\SessionInfo\getProvider(), MediaWiki\Session\SessionInfo\getProviderMetadata(), MediaWiki\Session\SessionInfo\getUserInfo(), MediaWiki\Session\SessionBackend\persist(), MediaWiki\MainConfigNames\PHPSessionHandling, MediaWiki\Session\SessionInfo\wasPersisted(), and MediaWiki\Session\SessionInfo\wasRemembered().
| MediaWiki\Session\SessionBackend::addData | ( | array | $newData | ) |
Add data to the session.
Overwrites any existing data under the same keys.
| array | $newData | Key-value pairs to add to the session |
Definition at line 628 of file SessionBackend.php.
References wfGetAllCallers().
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession().
| MediaWiki\Session\SessionBackend::canSetUser | ( | ) |
Whether the session user info can be changed.
Definition at line 483 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::delaySave | ( | ) |
Delay automatic saving while multiple updates are being made.
Calls to save() will not be delayed.
Definition at line 695 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::deregisterSession | ( | $index | ) |
Deregister a Session.
| int | $index |
Definition at line 246 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::dirty | ( | ) |
Mark data as dirty.
Definition at line 648 of file SessionBackend.php.
References wfGetAllCallers().
| MediaWiki\Session\SessionBackend::getAllowedUserRights | ( | ) |
Definition at line 465 of file SessionBackend.php.
| & MediaWiki\Session\SessionBackend::getData | ( | ) |
Fetch the session data array.
Note the caller is responsible for calling $this->dirty() if anything in the array is changed.
Definition at line 617 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::getId | ( | ) |
Return the session ID.
Definition at line 265 of file SessionBackend.php.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession().
| MediaWiki\Session\SessionBackend::getLoggedOutTimestamp | ( | ) |
| MediaWiki\Session\SessionBackend::getProvider | ( | ) |
Fetch the SessionProvider for this session.
Definition at line 334 of file SessionBackend.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\getAllowedUserRights(), and MediaWiki\Session\SessionProvider\getAllowedUserRights().
| MediaWiki\Session\SessionBackend::getProviderMetadata | ( | ) |
Fetch provider metadata.
Definition at line 583 of file SessionBackend.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\getAllowedUserRights().
| MediaWiki\Session\SessionBackend::getRequest | ( | $index | ) |
Return the request associated with a Session.
| int | $index | Session index |
Definition at line 446 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::getRestrictions | ( | ) |
Definition at line 474 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::getSession | ( | WebRequest | $request | ) |
Create a new Session for this backend.
| WebRequest | $request |
Definition at line 233 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::getSessionId | ( | ) |
Fetch the SessionId object.
Definition at line 275 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionManager\changeBackendId().
| MediaWiki\Session\SessionBackend::getUser | ( | ) |
Return the authenticated user for this session.
Definition at line 456 of file SessionBackend.php.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession().
| MediaWiki\Session\SessionBackend::isPersistent | ( | ) |
Whether this session is persisted across requests.
For example, if cookies are set.
Definition at line 343 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::persist | ( | bool | $force = false | ) |
Make this session persisted across requests by calling SessionProvider::persist() and saving the session data and metadata to the session store.
Mutable sessions are started by application code calling persist(), and then the session will exist until unpersist() is called, the session expires, or the client stops sending the session tokens needed by the SessionProvider to return a non-null value from provideSessionInfo(). Immutable sessions are started by the client sending the needed session tokens; persist() / unpersist() will only determine whether the session data is saved to the session store.
If the session is already persistent, persist() equivalent to calling $this->renew(), except when the $force flag is set.
Definition at line 361 of file SessionBackend.php.
Referenced by MediaWiki\Session\SessionBackend\__construct().
| MediaWiki\Session\SessionBackend::renew | ( | ) |
Renew the session by re-saving all data with a new TTL.
Resets the TTL in the backend store if the session is near expiring, and re-persists the session to any active WebRequests if persistent. No-op otherwise to reduce cookie churn in browsers.
Definition at line 665 of file SessionBackend.php.
References wfGetAllCallers().
| MediaWiki\Session\SessionBackend::resetId | ( | ) |
Change the session ID.
Definition at line 284 of file SessionBackend.php.
References MediaWiki\Session\PHPSessionHandler\isEnabled().
| MediaWiki\Session\SessionBackend::save | ( | $closing = false | ) |
Save the session.
Update both the backend data and the associated WebRequest(s) to reflect the state of the SessionBackend. This might include persisting or unpersisting the session.
| bool | $closing | Whether the session is being closed |
Definition at line 730 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::setForceHTTPS | ( | $force | ) |
Set whether HTTPS should be forced.
| bool | $force |
Definition at line 538 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::setLoggedOutTimestamp | ( | $ts = null | ) |
| int | null | $ts |
Definition at line 563 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::setProviderMetadata | ( | $metadata | ) |
| array | null | $metadata |
Definition at line 591 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::setRememberUser | ( | $remember | ) |
Set whether the user should be remembered, independently of the session ID.
| bool | $remember |
Definition at line 426 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::setUser | ( | $user | ) |
Set a new User object for this session.
TODO: Consider changing to a "UserIdentity" instead.
| User | $user | User to set on the session. |
Definition at line 496 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::shouldForceHTTPS | ( | ) |
Whether HTTPS should be forced.
Definition at line 530 of file SessionBackend.php.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\ImmutableSessionProviderWithCookie\persistSession().
| MediaWiki\Session\SessionBackend::shouldRememberUser | ( | ) |
Whether the user should be remembered, independently of the session ID.
Definition at line 417 of file SessionBackend.php.
Referenced by MediaWiki\Session\CookieSessionProvider\persistSession(), and MediaWiki\Session\CookieSessionProvider\setForceHTTPSCookie().
| MediaWiki\Session\SessionBackend::shutdown | ( | ) |
Shut down a session.
Definition at line 255 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::suggestLoginUsername | ( | $index | ) |
| int | $index | Session index |
Definition at line 519 of file SessionBackend.php.
| MediaWiki\Session\SessionBackend::unpersist | ( | ) |
Make this session not persisted across requests.
Definition at line 381 of file SessionBackend.php.
References MediaWiki\Session\PHPSessionHandler\isEnabled().