4 DEFINE(
'_DB_SESSION_HANDLER', getShopBasePath() .
'core/adodblite/session/adodb-session.php');
107 'login_noredirect' =>
true,
108 'tocomparelist' =>
true,
110 '_artperpage' =>
true,
112 'listorderby' =>
true,
156 $this->_sName = $sVal;
166 return $this->_sForcedPrefix . $this->
getName();
197 if ($sForceSidParam) {
198 $sid = $sForceSidParam;
201 } elseif ($sSidParam) {
210 self::$_blIsNewSession =
true;
213 self::$_blIsNewSession =
false;
219 if ($this->_sId != session_id()) {
225 if (!self::$_blIsNewSession && $blSwapped) {
229 if ($this->_sErrorMsg &&
$myConfig->getConfigParam(
'iDebug')) {
232 } elseif (!$blSwapped) {
246 return preg_replace(
'/[^a-z0-9]/i',
'', $this->
getConfig()->getRequestParameter(
'stoken'));
256 $sRet = preg_replace(
'/[^a-z0-9]/i',
'', $this->
getVariable(
'sess_stoken'));
293 $blSetNoCache =
true;
296 session_cache_limiter(
'nocache');
300 if (isset($_SERVER[
'HTTP_USER_AGENT']) &&
301 strpos($_SERVER[
'HTTP_USER_AGENT'],
'AOL') !==
false
304 session_cache_limiter(
false);
305 header(
"Cache-Control: no-store, private, must-revalidate, proxy-revalidate, post-check=0, pre-check=0, max-age=0, s-maxage=0");
313 include_once _DB_SESSION_HANDLER;
317 $this->_blStarted = @session_start();
331 if (self::$_blIsNewSession) {
336 $aPersistent = array();
337 foreach ($this->_aPersistentParams as $sParam) {
339 $aPersistent[$sParam] = $sValue;
346 foreach ($aPersistent as $sKey => $sParam) {
362 if (self::$_blIsNewSession) {
384 $sOldId = session_id();
386 $sNewId = session_id();
394 $oDB->execute(
"UPDATE oxsessions SET SessionID = " . $oDB->quote($sNewId) .
" WHERE SessionID = " . $oDB->quote($sOldId));
409 session_write_close();
431 if (defined(
'OXID_PHP_UNIT')) {
432 if (isset(modSession::$unitMOD) && is_object(modSession::$unitMOD)) {
434 $sVal = modSession::getInstance()->getVar($name);
443 return isset($_SESSION[$name]);
456 if (defined(
'OXID_PHP_UNIT')) {
457 if (isset(modSession::$unitMOD) && is_object(modSession::$unitMOD)) {
459 return modSession::getInstance()->setVar($name, $value);
466 $_SESSION[$name] = $value;
479 if (defined(
'OXID_PHP_UNIT')) {
480 if (isset(modSession::$unitMOD) && is_object(modSession::$unitMOD)) {
482 return modSession::getInstance()->getVar($name);
489 if (isset($_SESSION[$name])) {
490 return $_SESSION[$name];
505 if (defined(
'OXID_PHP_UNIT')) {
506 if (isset(modSession::$unitMOD) && is_object(modSession::$unitMOD)) {
508 return modSession::getInstance()->setVar($name, null);
515 $_SESSION[$name] = null;
517 unset($_SESSION[$name]);
529 public function sid($blForceSid =
false)
536 && is_array(
$myConfig->getConfigParam(
'aCacheViews'))
540 if (!$blDisableSid && $this->
getId() && ($blForceSid || !$blUseCookies || !$this->
_getCookieSid())) {
562 $sSid = $sToken =
'';
564 $sSid =
"<input type=\"hidden\" name=\"" . $this->
getForcedName() .
"\" value=\"" . $this->
getId() .
"\" />";
566 if ($this->
getId()) {
570 return $sToken . $sSid;
580 if ($this->_oBasket === null) {
585 oxNew(
'oxbasketitem');
588 $oEmptyBasket =
oxNew(
'oxbasket');
590 $oBasket = ($sBasket && ($oBasket = unserialize($sBasket))) ? $oBasket : null;
592 if (!$oBasket || (get_class($oBasket) !== get_class($oEmptyBasket))) {
593 $oBasket = $oEmptyBasket;
613 if (empty($aCurrContent)) {
618 foreach ($aCurrContent as $oContent) {
619 if ($oContent->getLanguageId() != $iCurrLang) {
620 $oContent->setLanguageId($iCurrLang);
633 $this->_oBasket = $oBasket;
661 $this->_blForceNewSession =
true;
684 if ($sUrl && !$oConfig->isCurrentUrl($sUrl)) {
686 } elseif ($this->_blSidNeeded === null) {
688 $this->_blSidNeeded =
false;
694 $this->_blSidNeeded =
false;
696 $this->_blSidNeeded =
true;
699 if ($blSidNeeded = $this->
getVariable(
'blSidNeeded')) {
700 $this->_blSidNeeded =
true;
703 if (!count($_COOKIE)) {
704 $this->_blSidNeeded =
true;
707 $this->
setVariable(
'blSidNeeded', $this->_blSidNeeded);
726 $blReturn = (isset($_COOKIE[$this->
getName()]) && ($_COOKIE[$this->
getName()] == $this->
getId()));
747 $sSid = $this->
sid($blSid);
752 $aUrlParts = explode(
'#', $sUrl);
753 if (!$oStr->preg_match(
'/(\?|&(amp;)?)sid=/i', $aUrlParts[0]) && (
false === $oStr->strpos($aUrlParts[0], $sSid))) {
754 if (!$oStr->preg_match(
'/(\?|&(amp;)?)$/', $sUrl)) {
755 $aUrlParts[0] .= ($oStr->strstr($aUrlParts[0],
'?') !==
false ?
'&' :
'?');
757 $aUrlParts[0] .= $sSid .
'&';
759 $sUrl = join(
'#', $aUrlParts);
778 if (!$sToken && $blGenerateNew) {
779 $sToken = md5(rand() . $this->
getId());
780 $sToken = substr($sToken, 0, 8);
805 $blAllowSessionStart =
true;
811 $blAllowSessionStart =
false;
813 $blAllowSessionStart =
true;
820 !(
$myConfig->getRequestParameter($this->getName()) ||
$myConfig->getRequestParameter($this->getForcedName())) &&
823 $blAllowSessionStart =
false;
828 return $blAllowSessionStart;
852 if (
$myConfig->getConfigParam(
'blAdodbSessionHandler')) {
857 $blDisableCookieCheck =
$myConfig->getConfigParam(
'blDisableCookieCheck');
859 if (!$blDisableCookieCheck && $blUseCookies) {
860 $blSwapped = $this->
_checkCookies($myUtilsServer->getOxCookie(
'sid_key'), $this->
getVariable(
"sessioncookieisset"));
884 $sAgent = $oUtils->processUserAgentInfo($sAgent);
885 $sExistingAgent = $oUtils->processUserAgentInfo($sExistingAgent);
887 if ($sAgent && $sAgent !== $sExistingAgent) {
888 if ($sExistingAgent) {
889 $this->_sErrorMsg =
"Different browser ({$sExistingAgent}, {$sAgent}), creating new SID...<br>";
908 $sSID = $oDb->getOne(
"select SessionID from oxsessions where SessionID = " . $oDb->quote($this->getId()));
912 if (!$this->_blNewSession && (!isset($sSID) || !$sSID)) {
914 $this->_sErrorMsg =
"Session has expired in the past and someone uses this sid to reactivate it, creating new SID...<br>";
937 $blSessCookieSetOnce =
false;
938 if (is_array($aSessCookieSetOnce) && isset($aSessCookieSetOnce[$sCurrUrl])) {
939 $blSessCookieSetOnce = $aSessCookieSetOnce[$sCurrUrl];
943 if ($blSessCookieSetOnce && !$sCookieSid) {
944 if (
$myConfig->getConfigParam(
'iDebug')) {
945 $this->_sErrorMsg =
"Cookie not found, creating new SID...<br>";
946 $this->_sErrorMsg .=
"Cookie: $sCookieSid<br>";
947 $this->_sErrorMsg .=
"Session: $blSessCookieSetOnce<br>";
948 $this->_sErrorMsg .=
"URL: " . $sCurrUrl .
"<br>";
954 if ($sCookieSid ==
"oxid" && !$blSessCookieSetOnce) {
955 if (!is_array($aSessCookieSetOnce)) {
956 $aSessCookieSetOnce = array();
959 $aSessCookieSetOnce[$sCurrUrl] =
"ox_true";
960 $this->
setVariable(
"sessioncookieisset", $aSessCookieSetOnce);
981 if ($sSessId && session_id() != $sSessId) {
982 $this->_blNewSession =
true;
985 session_id($sSessId);
987 $this->
setId($sSessId);
1013 if (
$myConfig->getConfigParam(
'blMallSharedBasket') == 0) {
1014 return $myConfig->getShopId() .
"_basket";
1038 $aCfgArray = $this->
getConfig()->getConfigParam(
'aRequireSessionWithParams');
1039 if (is_array($aCfgArray)) {
1041 foreach ($aCfgArray as $key => $val) {
1042 if (!is_array($val) && $val) {
1043 unset($aDefault[$key]);
1047 return array_merge_recursive($aCfgArray, $aDefault);
1061 $sValue = $this->
getConfig()->getRequestParameter($sParam);
1062 if (isset($sValue)) {
1063 if (is_array($aValues)) {
1064 if (isset($aValues[$sValue]) && $aValues[$sValue]) {
1067 } elseif ($aValues) {
1073 return (isset($_SERVER[
'REQUEST_METHOD']) && $_SERVER[
'REQUEST_METHOD'] ==
'POST');
1083 return $this->
isAdmin() || $this->
getConfig()->getConfigParam(
'blSessionUseCookies');
1093 $sInputToken = $this->
getConfig()->getRequestParameter(
'rtoken');
1095 $blValid = !empty($sInputToken) ? ($sToken === $sInputToken) :
false;
1107 if (!$this->_oBasketReservations) {
1108 $this->_oBasketReservations =
oxNew(
'oxBasketReservation');
1121 return headers_sent();