9use InvalidArgumentException;
41 parent::__construct();
43 if ( isset( $params[
'sessionCookieName'] ) ) {
44 if ( !is_string( $params[
'sessionCookieName'] ) ) {
45 throw new InvalidArgumentException(
'sessionCookieName must be a string' );
47 $this->sessionCookieName = $params[
'sessionCookieName'];
49 if ( isset( $params[
'sessionCookieOptions'] ) ) {
50 if ( !is_array( $params[
'sessionCookieOptions'] ) ) {
51 throw new InvalidArgumentException(
'sessionCookieOptions must be an array' );
53 $this->sessionCookieOptions = $params[
'sessionCookieOptions'];
69 if ( $this->sessionCookieName ===
null ) {
70 throw new \BadMethodCallException(
71 __METHOD__ .
' may not be called when $this->sessionCookieName === null'
75 $prefix = $this->sessionCookieOptions[
'prefix']
77 $id = $request->
getCookie( $this->sessionCookieName, $prefix );
86 return $this->sessionCookieName !==
null;
102 if ( $this->sessionCookieName ===
null ) {
107 if ( $response->headersSent() ) {
109 $this->logger->debug( __METHOD__ .
': Headers already sent' );
117 $response->setCookie(
'forceHTTPS',
'true',
null,
118 [
'prefix' =>
'',
'secure' =>
false ] + $options );
120 $options[
'secure'] =
true;
123 $response->setCookie( $this->sessionCookieName, $session->
getId(),
null, $options );
131 if ( $this->sessionCookieName ===
null ) {
136 if ( $response->headersSent() ) {
138 $this->logger->debug( __METHOD__ .
': Headers already sent' );
142 $response->clearCookie( $this->sessionCookieName, $this->sessionCookieOptions );
150 if ( $this->sessionCookieName ===
null ) {
154 $prefix = $this->sessionCookieOptions[
'prefix'] ??
161 return wfMessage(
'sessionprovider-nocookies' );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
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()