Fix for r47482: put the RELEASE-NOTES entry in the "bug fixes" section and not the...
[mediawiki.git] / includes / WebResponse.php
blob09d373850fc7d378c5bfef8a4cf8a7242af1a332
1 <?php
2 /**
3 * Allow programs to request this object from WebRequest::response()
4 * and handle all outputting (or lack of outputting) via it.
5 * @ingroup HTTP
6 */
7 class WebResponse {
9 /**
10 * Output a HTTP header, wrapper for PHP's
11 * header()
12 * @param $string String: header to output
13 * @param $replace Bool: replace current similar header
15 public function header($string, $replace=true) {
16 header($string,$replace);
19 /** Set the browser cookie
20 * @param $name String: name of cookie
21 * @param $value String: value to give cookie
22 * @param $expire Int: number of seconds til cookie expires
24 public function setcookie( $name, $value, $expire = 0 ) {
25 global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain;
26 global $wgCookieSecure,$wgCookieExpiration, $wgCookieHttpOnly;
27 if ( $expire == 0 ) {
28 $expire = time() + $wgCookieExpiration;
30 $httpOnlySafe = wfHttpOnlySafe();
31 wfDebugLog( 'cookie',
32 'setcookie: "' . implode( '", "',
33 array(
34 $wgCookiePrefix . $name,
35 $value,
36 $expire,
37 $wgCookiePath,
38 $wgCookieDomain,
39 $wgCookieSecure,
40 $httpOnlySafe && $wgCookieHttpOnly ) ) . '"' );
41 if( $httpOnlySafe && isset( $wgCookieHttpOnly ) ) {
42 setcookie( $wgCookiePrefix . $name,
43 $value,
44 $expire,
45 $wgCookiePath,
46 $wgCookieDomain,
47 $wgCookieSecure,
48 $wgCookieHttpOnly );
49 } else {
50 // setcookie() fails on PHP 5.1 if you give it future-compat paramters.
51 // stab stab!
52 setcookie( $wgCookiePrefix . $name,
53 $value,
54 $expire,
55 $wgCookiePath,
56 $wgCookieDomain,
57 $wgCookieSecure );