37 public function header( $string, $replace =
true, $http_response_code =
null ) {
38 if ( substr( $string, 0, 5 ) ==
'HTTP/' ) {
39 $parts = explode(
' ', $string, 3 );
40 $this->code = intval( $parts[1] );
42 list( $key, $val ) = array_map(
'trim', explode(
":", $string, 2 ) );
44 $key = strtoupper( $key );
46 if ( $replace || !isset( $this->headers[$key] ) ) {
47 $this->headers[$key] = $val;
51 if ( $http_response_code !==
null ) {
52 $this->code = intval( $http_response_code );
61 $this->code = intval(
$code );
73 $key = strtoupper( $key );
75 return $this->headers[$key] ??
null;
93 public function setCookie( $name, $value, $expire = 0, $options = [] ) {
97 $options = array_filter( $options,
function ( $a ) {
108 if ( $expire ===
null ) {
114 $this->cookies[$options[
'prefix'] . $name] = [
115 'value' => (string)$value,
116 'expire' => (
int)$expire,
117 'path' => (string)$options[
'path'],
118 'domain' => (
string)$options[
'domain'],
119 'secure' => (bool)$options[
'secure'],
120 'httpOnly' => (
bool)$options[
'httpOnly'],
121 'raw' => (bool)$options[
'raw'],
130 if ( isset( $this->cookies[$name] ) ) {
131 return $this->cookies[$name][
'value'];
141 return $this->cookies[$name] ??
null;
$wgCookieExpiration
Default cookie lifetime, in seconds.
$wgCookieHttpOnly
Set authentication cookies to HttpOnly to prevent access by JavaScript, in browsers that support this...
$wgCookiePath
Set this variable if you want to restrict cookies to a certain path within the domain specified by $w...
$wgCookieDomain
Set to set an explicit domain on the login cookies eg, "justthis.domain.org" or "....
$wgCookieSecure
Whether the "secure" flag should be set on the cookie.
$wgCookiePrefix
Cookies generated by MediaWiki have names starting with this prefix.
header( $string, $replace=true, $http_response_code=null)
Stores a HTTP header.
setCookie( $name, $value, $expire=0, $options=[])
getStatusCode()
Get the HTTP response code, null if not set.
headersSent()
Test if headers have been sent.
Allow programs to request this object from WebRequest::response() and handle all outputting (or lack ...