• Модуль: statistic
  • Путь к файлу: ~/bitrix/modules/statistic/classes/general/keepstatistic.php
  • Класс: CKeepStatistics
  • Вызов: CKeepStatistics::RestoreSession
static function RestoreSession()
{
	global $APPLICATION;
	// if there is no session ID
	if(!isset($_SESSION["SESS_SESSION_ID"]) || intval($_SESSION["SESS_SESSION_ID"]) <= 0)
	{
		if(COption::GetOptionString("statistic", "SAVE_SESSION_DATA") == "Y")
		{
			// try to use coockie
			$COOKIE_GUEST_ID = intval($APPLICATION->get_cookie("GUEST_ID"));
			if($COOKIE_GUEST_ID <= 0)
			{
				// restore session data from b_stat_session_data
				$z = CStatistics::GetSessionDataByMD5(get_guest_md5());
				if($zr = $z->Fetch())
				{
					$arrSESSION_DATA = unserialize($zr["SESSION_DATA"], ['allowed_classes' => false]);
					if(is_array($arrSESSION_DATA))
					{
						foreach($arrSESSION_DATA as $key => $value)
							$_SESSION[$key] = $value;
					}
					return intval($zr["ID"]); //Guest was found
				}
				return true; //Just tried to restore session data
			}
		}
	}
	return false; //We have no choice to restore guest session
}