56 parent::__construct();
58 if ( isset( $params[
'sessionCookieName'] ) ) {
59 if ( !is_string( $params[
'sessionCookieName'] ) ) {
60 throw new \InvalidArgumentException(
'sessionCookieName must be a string' );
62 $this->sessionCookieName = $params[
'sessionCookieName'];
64 if ( isset( $params[
'sessionCookieOptions'] ) ) {
65 if ( !is_array( $params[
'sessionCookieOptions'] ) ) {
66 throw new \InvalidArgumentException(
'sessionCookieOptions must be an array' );
68 $this->sessionCookieOptions = $params[
'sessionCookieOptions'];
84 if ( $this->sessionCookieName ===
null ) {
85 throw new \BadMethodCallException(
86 __METHOD__ .
' may not be called when $this->sessionCookieName === null'
90 $prefix = $this->sessionCookieOptions[
'prefix'] ?? $this->
getConfig()->get(
'CookiePrefix' );
91 $id = $request->
getCookie( $this->sessionCookieName, $prefix );
100 return $this->sessionCookieName !==
null;
116 if ( $this->sessionCookieName ===
null ) {
121 if ( $response->headersSent() ) {
123 $this->logger->debug( __METHOD__ .
': Headers already sent' );
130 if ( !$this->
getConfig()->
get(
'ForceHTTPS' ) ) {
131 $response->setCookie(
'forceHTTPS',
'true',
null,
132 [
'prefix' =>
'',
'secure' =>
false ] + $options );
134 $options[
'secure'] =
true;
137 $response->setCookie( $this->sessionCookieName, $session->
getId(),
null, $options );
145 if ( $this->sessionCookieName ===
null ) {
150 if ( $response->headersSent() ) {
152 $this->logger->debug( __METHOD__ .
': Headers already sent' );
156 $response->clearCookie( $this->sessionCookieName, $this->sessionCookieOptions );
164 if ( $this->sessionCookieName ===
null ) {
168 $prefix = $this->sessionCookieOptions[
'prefix'] ?? $this->
getConfig()->get(
'CookiePrefix' );
173 return wfMessage(
'sessionprovider-nocookies' );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
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.