本文整理汇总了PHP中Pimcore\Tool\Session::isSessionCookieCleanupNeeded方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::isSessionCookieCleanupNeeded方法的具体用法?PHP Session::isSessionCookieCleanupNeeded怎么用?PHP Session::isSessionCookieCleanupNeeded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Tool\Session
的用法示例。
在下文中一共展示了Session::isSessionCookieCleanupNeeded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: outputBufferEnd
/**
* if this method is called in self::shutdown() it forces the browser to close the connection an allows the
* shutdown-function to run in the background
* @static
* @return string
*/
public static function outputBufferEnd($data)
{
$output = null;
$contentEncoding = null;
if (headers_sent()) {
return $data;
}
// cleanup admin session Set-Cookie headers if needed
// a detailed description why this is necessary can be found in the doc-block of \Pimcore\Tool\Session::$sessionCookieCleanupNeeded
if (Tool\Session::isSessionCookieCleanupNeeded()) {
$headers = headers_list();
$headers = array_reverse($headers);
foreach ($headers as $header) {
if (strpos($header, Tool\Session::getOption("name")) !== false) {
header($header, true);
// setting the header again with 2nd arg = true, overrides all duplicates
break;
}
}
}
// only send this headers in the shutdown-function, so that it is also possible to get the contents of this buffer earlier without sending headers
if (self::$inShutdown) {
// force closing the connection at the client, this enables to do certain tasks (writing the cache) in the "background"
header("Connection: close\r\n");
// check for supported content-encodings
if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false) {
$contentEncoding = "gzip";
}
if (!empty($data) && $contentEncoding) {
ignore_user_abort(true);
// find the content-type of the response
$front = \Zend_Controller_Front::getInstance();
$a = $front->getResponse()->getHeaders();
$b = array_merge(headers_list(), $front->getResponse()->getRawHeaders());
$contentType = null;
// first check headers in headers_list() because they overwrite all other headers => see SOAP controller
foreach ($b as $header) {
if (stripos($header, "content-type") !== false) {
$parts = explode(":", $header);
if (strtolower(trim($parts[0])) == "content-type") {
$contentType = trim($parts[1]);
break;
}
}
}
if (!$contentType) {
foreach ($a as $header) {
if (strtolower(trim($header["name"])) == "content-type") {
$contentType = $header["value"];
break;
}
}
}
// prepare the response to be sent (gzip or not)
// do not add text/xml or a wildcard for text/* here because this causes problems with the SOAP server
$gzipContentTypes = array("@text/html@i", "@application/json@", "@text/javascript@", "@text/css@");
$gzipIt = false;
foreach ($gzipContentTypes as $type) {
if (@preg_match($type, $contentType)) {
$gzipIt = true;
break;
}
}
// gzip the contents and send connection close tthat the process can run in the background to finish
// some tasks like writing the cache ...
// using mb_strlen() because of PIMCORE-1509
if ($gzipIt) {
$output = "‹" . substr(gzcompress($data, 2), 0, -4) . pack('V', crc32($data)) . pack('V', mb_strlen($data, "latin1"));
// (although all modern browsers don't need it anymore) to work properly with google adwords check & co.
header("Content-Encoding: {$contentEncoding}\r\n");
}
}
// no gzip/deflate encoding
if (!$output) {
$output = $data;
}
if (strlen($output) > 0) {
// check here if there is actually content, otherwise readfile() and similar functions are not working anymore
header("Content-Length: " . mb_strlen($output, "latin1"));
}
header("X-Powered-By: pimcore", true);
}
// return the data unchanged
return $output;
}