54 parent::__construct();
56 if ( isset( $params[
'sessionCookieName'] ) ) {
57 if ( !is_string( $params[
'sessionCookieName'] ) ) {
58 throw new \InvalidArgumentException(
'sessionCookieName must be a string' );
60 $this->sessionCookieName = $params[
'sessionCookieName'];
62 if ( isset( $params[
'sessionCookieOptions'] ) ) {
63 if ( !is_array( $params[
'sessionCookieOptions'] ) ) {
64 throw new \InvalidArgumentException(
'sessionCookieOptions must be an array' );
66 $this->sessionCookieOptions = $params[
'sessionCookieOptions'];
82 if ( $this->sessionCookieName ===
null ) {
83 throw new \BadMethodCallException(
84 __METHOD__ .
' may not be called when $this->sessionCookieName === null'
88 $prefix = $this->sessionCookieOptions[
'prefix'] ?? $this->config->get(
'CookiePrefix' );
89 $id = $request->
getCookie( $this->sessionCookieName, $prefix );
94 return $this->sessionCookieName !==
null;
102 if ( $this->sessionCookieName ===
null ) {
109 $this->logger->debug( __METHOD__ .
': Headers already sent' );
116 if ( !$this->config->get(
'ForceHTTPS' ) ) {
117 $response->setCookie(
'forceHTTPS',
'true',
null,
118 [
'prefix' =>
'',
'secure' =>
false ] + $options );
120 $options[
'secure'] =
true;
123 $response->setCookie( $this->sessionCookieName, $session->
getId(),
null, $options );
127 if ( $this->sessionCookieName ===
null ) {
134 $this->logger->debug( __METHOD__ .
': Headers already sent' );
138 $response->clearCookie( $this->sessionCookieName, $this->sessionCookieOptions );
142 if ( $this->sessionCookieName ===
null ) {
146 $prefix = $this->sessionCookieOptions[
'prefix'] ?? $this->config->get(
'CookiePrefix' );
151 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.