57 parent::__construct();
59 if ( isset( $params[
'sessionCookieName'] ) ) {
60 if ( !is_string( $params[
'sessionCookieName'] ) ) {
61 throw new \InvalidArgumentException(
'sessionCookieName must be a string' );
63 $this->sessionCookieName = $params[
'sessionCookieName'];
65 if ( isset( $params[
'sessionCookieOptions'] ) ) {
66 if ( !is_array( $params[
'sessionCookieOptions'] ) ) {
67 throw new \InvalidArgumentException(
'sessionCookieOptions must be an array' );
69 $this->sessionCookieOptions = $params[
'sessionCookieOptions'];
85 if ( $this->sessionCookieName ===
null ) {
86 throw new \BadMethodCallException(
87 __METHOD__ .
' may not be called when $this->sessionCookieName === null'
91 $prefix = $this->sessionCookieOptions[
'prefix']
93 $id = $request->
getCookie( $this->sessionCookieName, $prefix );
102 return $this->sessionCookieName !==
null;
118 if ( $this->sessionCookieName ===
null ) {
123 if ( $response->headersSent() ) {
125 $this->logger->debug( __METHOD__ .
': Headers already sent' );
133 $response->setCookie(
'forceHTTPS',
'true',
null,
134 [
'prefix' =>
'',
'secure' =>
false ] + $options );
136 $options[
'secure'] =
true;
139 $response->setCookie( $this->sessionCookieName, $session->
getId(),
null, $options );
147 if ( $this->sessionCookieName ===
null ) {
152 if ( $response->headersSent() ) {
154 $this->logger->debug( __METHOD__ .
': Headers already sent' );
158 $response->clearCookie( $this->sessionCookieName, $this->sessionCookieOptions );
166 if ( $this->sessionCookieName ===
null ) {
170 $prefix = $this->sessionCookieOptions[
'prefix'] ??
176 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()
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
response()
Return a handle to WebResponse style object, for setting cookies, headers and other stuff,...
getCookie( $key, $prefix=null, $default=null)
Get a cookie from the $_COOKIE jar.