26use InvalidArgumentException;
58 parent::__construct();
60 if ( isset(
$params[
'sessionCookieName'] ) ) {
61 if ( !is_string(
$params[
'sessionCookieName'] ) ) {
62 throw new InvalidArgumentException(
'sessionCookieName must be a string' );
64 $this->sessionCookieName =
$params[
'sessionCookieName'];
66 if ( isset(
$params[
'sessionCookieOptions'] ) ) {
67 if ( !is_array(
$params[
'sessionCookieOptions'] ) ) {
68 throw new InvalidArgumentException(
'sessionCookieOptions must be an array' );
70 $this->sessionCookieOptions =
$params[
'sessionCookieOptions'];
86 if ( $this->sessionCookieName ===
null ) {
87 throw new \BadMethodCallException(
88 __METHOD__ .
' may not be called when $this->sessionCookieName === null'
92 $prefix = $this->sessionCookieOptions[
'prefix']
94 $id = $request->
getCookie( $this->sessionCookieName, $prefix );
103 return $this->sessionCookieName !==
null;
119 if ( $this->sessionCookieName ===
null ) {
124 if ( $response->headersSent() ) {
126 $this->logger->debug( __METHOD__ .
': Headers already sent' );
134 $response->setCookie(
'forceHTTPS',
'true',
null,
135 [
'prefix' =>
'',
'secure' =>
false ] + $options );
137 $options[
'secure'] =
true;
140 $response->setCookie( $this->sessionCookieName, $session->
getId(),
null, $options );
148 if ( $this->sessionCookieName ===
null ) {
153 if ( $response->headersSent() ) {
155 $this->logger->debug( __METHOD__ .
': Headers already sent' );
159 $response->clearCookie( $this->sessionCookieName, $this->sessionCookieOptions );
167 if ( $this->sessionCookieName ===
null ) {
171 $prefix = $this->sessionCookieOptions[
'prefix'] ??
177 return wfMessage(
'sessionprovider-nocookies' );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
array $params
The job parameters.
A class containing constants representing the names of configuration variables.
const ForceHTTPS
Name constant for the ForceHTTPS setting, for use with Config::get()
const CookiePrefix
Name constant for the CookiePrefix setting, for use with Config::get()