3 * MediaWiki\Session entry point interface
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 namespace MediaWiki\Session
;
26 use Psr\Log\LoggerAwareInterface
;
31 * This exists to make IDEs happy, so they don't see the
32 * internal-but-required-to-be-public methods on SessionManager.
37 interface SessionManagerInterface
extends LoggerAwareInterface
{
39 * Fetch the session for a request
41 * @note You probably want to use $request->getSession() instead. It's more
42 * efficient and doesn't break FauxRequests or sessions that were changed
43 * by $this->getSessionById() or $this->getEmptySession().
44 * @param WebRequest $request Any existing associated session will be reset
45 * to the session corresponding to the data in the request itself.
47 * @throws \OverflowException if there are multiple sessions tied for top
48 * priority in the request. Exception has a property "sessionInfos"
49 * holding the SessionInfo objects for the sessions involved.
51 public function getSessionForRequest( WebRequest
$request );
54 * Fetch a session by ID
56 * @param bool $create If no session exists for $id, try to create a new one.
57 * May still return null if a session for $id exists but cannot be loaded.
58 * @param WebRequest|null $request Corresponding request. Any existing
59 * session associated with this WebRequest object will be overwritten.
60 * @return Session|null
62 public function getSessionById( $id, $create = false, WebRequest
$request = null );
65 * Fetch a new, empty session
67 * The first provider configured that is able to provide an empty session
70 * @param WebRequest|null $request Corresponding request. Any existing
71 * session associated with this WebRequest object will be overwritten.
74 public function getEmptySession( WebRequest
$request = null );
77 * Invalidate sessions for a user
79 * After calling this, existing sessions should be invalid. For mutable
80 * session providers, this generally means the user has to log in again;
81 * for immutable providers, it generally means the loss of session data.
85 public function invalidateSessionsForUser( User
$user );
88 * Return the HTTP headers that need varying on.
90 * The return value is such that someone could theoretically do this:
92 * foreach ( $provider->getVaryHeaders() as $header => $options ) {
93 * $outputPage->addVaryHeader( $header, $options );
99 public function getVaryHeaders();
102 * Return the list of cookies that need varying on.
105 public function getVaryCookies();