function RestoreSession() { global $APPLICATION; // if there is no session ID if (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"]); 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 }