本文整理汇总了PHP中CUserOptions::SetCookieOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP CUserOptions::SetCookieOptions方法的具体用法?PHP CUserOptions::SetCookieOptions怎么用?PHP CUserOptions::SetCookieOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUserOptions
的用法示例。
在下文中一共展示了CUserOptions::SetCookieOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PrologActions
function PrologActions()
{
/** @global CMain $APPLICATION */
global $APPLICATION, $USER;
if (defined("BX_CHECK_SHORT_URI") && BX_CHECK_SHORT_URI) {
if ($arUri = CBXShortUri::GetUri($_SERVER["REQUEST_URI"])) {
CBXShortUri::SetLastUsed($arUri["ID"]);
if (CModule::IncludeModule("statistic")) {
CStatEvent::AddCurrent("short_uri_redirect", "", "", "", "", $arUri["URI"], "N", SITE_ID);
}
LocalRedirect($arUri["URI"], true, CBXShortUri::GetHttpStatusCodeText($arUri["STATUS"]));
die;
}
}
//session expander
if (COption::GetOptionString("main", "session_expand", "Y") != "N" && (!defined("BX_SKIP_SESSION_EXPAND") || BX_SKIP_SESSION_EXPAND == false)) {
$arPolicy = $USER->GetSecurityPolicy();
$phpSessTimeout = ini_get("session.gc_maxlifetime");
if ($arPolicy["SESSION_TIMEOUT"] > 0) {
$sessTimeout = min($arPolicy["SESSION_TIMEOUT"] * 60, $phpSessTimeout);
} else {
$sessTimeout = $phpSessTimeout;
}
$cookie_prefix = COption::GetOptionString('main', 'cookie_name', 'BITRIX_SM');
$salt = $_COOKIE[$cookie_prefix . '_UIDH'] . "|" . $_SERVER["REMOTE_ADDR"] . "|" . @filemtime($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/version.php") . "|" . LICENSE_KEY . "|" . CMain::GetServerUniqID();
$key = md5(bitrix_sessid() . $salt);
$bShowMess = $USER->IsAuthorized() && COption::GetOptionString("main", "session_show_message", "Y") != "N";
$ext = array('ajax');
if ($bShowMess) {
$ext[] = "fx";
}
CUtil::InitJSCore($ext);
$jsMsg = '<script type="text/javascript">' . "\n" . ($bShowMess ? 'bxSession.mess.messSessExpired = \'' . CUtil::JSEscape(GetMessage("MAIN_SESS_MESS", array("#TIMEOUT#" => round($sessTimeout / 60)))) . '\';' . "\n" : '') . 'bxSession.Expand(' . $sessTimeout . ', \'' . bitrix_sessid() . '\', ' . ($bShowMess ? 'true' : 'false') . ', \'' . $key . '\');' . "\n" . '</script>';
if ($APPLICATION->IsJSOptimized()) {
$APPLICATION->AddHeadScript('/bitrix/js/main/session.js');
$APPLICATION->AddAdditionalJS($jsMsg);
} else {
$APPLICATION->AddHeadString('<script type="text/javascript" src="' . CUtil::GetAdditionalFileURL('/bitrix/js/main/session.js') . '"></script>' . "\n" . $jsMsg, true);
}
$_SESSION["BX_SESSION_COUNTER"] = intval($_SESSION["BX_SESSION_COUNTER"]) + 1;
if (!defined("BX_SKIP_SESSION_TERMINATE_TIME")) {
$_SESSION["BX_SESSION_TERMINATE_TIME"] = time() + $sessTimeout;
}
}
//user auto time zone via js cookies
if (CTimeZone::Enabled()) {
CTimeZone::SetAutoCookie();
}
// check user options set via cookie
if ($USER->IsAuthorized()) {
$cookieName = COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_LAST_SETTINGS";
if (!empty($_COOKIE[$cookieName])) {
CUserOptions::SetCookieOptions($cookieName);
}
}
if (COption::GetOptionString("main", "buffer_content", "Y") == "Y" && (!defined("BX_BUFFER_USED") || BX_BUFFER_USED !== true)) {
ob_start(array(&$APPLICATION, "EndBufferContent"));
$APPLICATION->buffered = true;
define("BX_BUFFER_USED", true);
register_shutdown_function(create_function('', 'while(@ob_end_flush());'));
}
foreach (GetModuleEvents("main", "OnProlog", true) as $arEvent) {
ExecuteModuleEventEx($arEvent);
}
}
示例2: PrologActions
public static function PrologActions()
{
/** @global CMain $APPLICATION */
global $APPLICATION, $USER;
if (COption::GetOptionString("main", "buffer_content", "Y") == "Y" && (!defined("BX_BUFFER_USED") || BX_BUFFER_USED !== true)) {
ob_start(array(&$APPLICATION, "EndBufferContent"));
$APPLICATION->buffered = true;
// define("BX_BUFFER_USED", true);
register_shutdown_function(function () {
// define("BX_BUFFER_SHUTDOWN", true);
for ($i = 0, $n = ob_get_level(); $i < $n; $i++) {
ob_end_flush();
}
});
}
//session expander
if (COption::GetOptionString("main", "session_expand", "Y") != "N" && (!defined("BX_SKIP_SESSION_EXPAND") || BX_SKIP_SESSION_EXPAND === false)) {
//only for authorized
if (COption::GetOptionString("main", "session_auth_only", "Y") != "Y" || $USER->IsAuthorized()) {
$arPolicy = $USER->GetSecurityPolicy();
$phpSessTimeout = ini_get("session.gc_maxlifetime");
if ($arPolicy["SESSION_TIMEOUT"] > 0) {
$sessTimeout = min($arPolicy["SESSION_TIMEOUT"] * 60, $phpSessTimeout);
} else {
$sessTimeout = $phpSessTimeout;
}
$cookie_prefix = COption::GetOptionString('main', 'cookie_name', 'BITRIX_SM');
$salt = $_COOKIE[$cookie_prefix . '_UIDH'] . "|" . $USER->GetID() . "|" . $_SERVER["REMOTE_ADDR"] . "|" . @filemtime($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/version.php") . "|" . LICENSE_KEY . "|" . CMain::GetServerUniqID();
$key = md5(bitrix_sessid() . $salt);
$bShowMess = $USER->IsAuthorized() && COption::GetOptionString("main", "session_show_message", "Y") != "N";
CUtil::InitJSCore(array('ajax', 'ls'));
$jsMsg = '<script type="text/javascript">' . "\n" . ($bShowMess ? 'bxSession.mess.messSessExpired = \'' . CUtil::JSEscape(GetMessage("MAIN_SESS_MESS", array("#TIMEOUT#" => round($sessTimeout / 60)))) . '\';' . "\n" : '') . 'bxSession.Expand(' . $sessTimeout . ', \'' . bitrix_sessid() . '\', ' . ($bShowMess ? 'true' : 'false') . ', \'' . $key . '\');' . "\n" . '</script>';
$APPLICATION->AddHeadScript('/bitrix/js/main/session.js');
$APPLICATION->AddAdditionalJS($jsMsg);
$_SESSION["BX_SESSION_COUNTER"] = intval($_SESSION["BX_SESSION_COUNTER"]) + 1;
if (!defined("BX_SKIP_SESSION_TERMINATE_TIME")) {
$_SESSION["BX_SESSION_TERMINATE_TIME"] = time() + $sessTimeout;
}
}
}
//user auto time zone via js cookies
if (CTimeZone::Enabled() && (!defined("BX_SKIP_TIMEZONE_COOKIE") || BX_SKIP_TIMEZONE_COOKIE === false)) {
CTimeZone::SetAutoCookie();
}
// check user options set via cookie
if ($USER->IsAuthorized()) {
$cookieName = COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_LAST_SETTINGS";
if (!empty($_COOKIE[$cookieName])) {
CUserOptions::SetCookieOptions($cookieName);
}
}
foreach (GetModuleEvents("main", "OnProlog", true) as $arEvent) {
ExecuteModuleEventEx($arEvent);
}
}