diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 02e349330..ae5403692 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -358,6 +358,7 @@ class Context } else { + $this->isSessionStarted = FALSE; $_SESSION = array(); } @@ -475,6 +476,26 @@ class Context session_write_close(); } + /** + * set Cache-Control header + * + * @return void + */ + function setCacheControl($public = 'public', $nocache = false) + { + is_a($this, 'Context') ? $self = $this : $self = self::getInstance(); + + $public = !empty($public) ? $public.', ' : ''; + header("Cache-Control: ".$public."must-revalidate, post-check=0, pre-check=0"); + if ($nocache) + { + header("Cache-Control: no-store, no-cache, must-revalidate", false); + header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header("Pragma: no-cache"); + } + } + /** * Load the database information * diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php index ca160a57c..8c89f138d 100644 --- a/classes/display/DisplayHandler.class.php +++ b/classes/display/DisplayHandler.class.php @@ -324,11 +324,6 @@ class DisplayHandler extends Handler function _printXMLHeader() { header("Content-Type: text/xml; charset=UTF-8"); - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); - header("Cache-Control: no-store, no-cache, must-revalidate"); - header("Cache-Control: post-check=0, pre-check=0", false); - header("Pragma: no-cache"); } /** @@ -338,11 +333,6 @@ class DisplayHandler extends Handler function _printHTMLHeader() { header("Content-Type: text/html; charset=UTF-8"); - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); - header("Cache-Control: no-store, no-cache, must-revalidate"); - header("Cache-Control: post-check=0, pre-check=0", false); - header("Pragma: no-cache"); } /** @@ -352,11 +342,6 @@ class DisplayHandler extends Handler function _printJSONHeader() { header("Content-Type: text/html; charset=UTF-8"); - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); - header("Cache-Control: no-store, no-cache, must-revalidate"); - header("Cache-Control: post-check=0, pre-check=0", false); - header("Pragma: no-cache"); } /** diff --git a/classes/mobile/Mobile.class.php b/classes/mobile/Mobile.class.php index c38ffcf21..db2ac82aa 100644 --- a/classes/mobile/Mobile.class.php +++ b/classes/mobile/Mobile.class.php @@ -123,13 +123,13 @@ class Mobile setcookie("mobile", 'true', 0, $xe_web_path); } } - elseif($_COOKIE['mobile'] != 'false') + elseif(isset($_COOKIE['mobile']) && $_COOKIE['mobile'] != 'false') { $_COOKIE['mobile'] = 'false'; setcookie("mobile", 'false', 0, $xe_web_path); } - if($_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT'])) + if(isset($_COOKIE['mobile']) && $_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT'])) { setcookie("user-agent", md5($_SERVER['HTTP_USER_AGENT']), 0, $xe_web_path); }