3 DEFINE(
'_DB_SESSION_HANDLER', getShopBasePath() .
'core/adodblite/session/adodb-session.php');
108 'login_noredirect' =>
true,
109 'tocomparelist' =>
true,
111 '_artperpage' =>
true,
113 'listorderby' =>
true,
173 $this->_sName = $sVal;
183 return $this->_sForcedPrefix . $this->
getName();
216 if ($sForceSidParam) {
217 $sid = $sForceSidParam;
220 } elseif ($sSidParam) {
229 self::$_blIsNewSession =
true;
232 self::$_blIsNewSession =
false;
238 if ( $this->_sId != session_id() ) {
244 if ( !self::$_blIsNewSession && $blSwapped ) {
248 if ( $this->_sErrorMsg &&
$myConfig->getConfigParam(
'iDebug' ) ) {
251 } elseif ( !$blSwapped ) {
265 return preg_replace(
'/[^a-z0-9]/i',
'', $this->
getConfig()->getRequestParameter(
'stoken') );
275 $sRet = preg_replace(
'/[^a-z0-9]/i',
'', $this->
getVariable(
'sess_stoken' ) );
312 $blSetNoCache =
true;
313 if ( $blSetNoCache ) {
315 session_cache_limiter(
'nocache' );
319 if ( isset( $_SERVER[
'HTTP_USER_AGENT'] ) &&
320 strpos( $_SERVER[
'HTTP_USER_AGENT'],
'AOL' ) !==
false ) {
322 session_cache_limiter(
false);
323 header(
"Cache-Control: no-store, private, must-revalidate, proxy-revalidate, post-check=0, pre-check=0, max-age=0, s-maxage=0");
330 include_once _DB_SESSION_HANDLER;
333 $this->_blStarted = @session_start();
349 if ( self::$_blIsNewSession ) {
354 $aPersistent = array();
355 foreach ( $this->_aPersistentParams as $sParam ) {
356 if ( ( $sValue = $this->
getVariable( $sParam ) ) ) {
357 $aPersistent[$sParam] = $sValue;
364 foreach ( $aPersistent as $sKey => $sParam ) {
382 if ( self::$_blIsNewSession ) {
403 $sOldId = session_id();
405 $sNewId = session_id();
413 $oDB->execute(
"UPDATE oxsessions SET SessionID = ".$oDB->quote( $sNewId ).
" WHERE SessionID = ".$oDB->quote( $sOldId ) );
429 session_write_close();
467 if ( defined(
'OXID_PHP_UNIT' ) ) {
468 if ( isset( modSession::$unitMOD ) && is_object( modSession::$unitMOD ) ) {
471 return isset( $sVal );
478 return isset( $_SESSION[$name] );
491 public static function setVar( $name, $value )
507 if ( defined(
'OXID_PHP_UNIT' ) ) {
508 if ( isset( modSession::$unitMOD ) && is_object( modSession::$unitMOD ) ) {
517 $_SESSION[$name] = $value;
544 if ( defined(
'OXID_PHP_UNIT' ) ) {
545 if ( isset( modSession::$unitMOD ) && is_object( modSession::$unitMOD ) ) {
554 if ( isset( $_SESSION[$name] )) {
555 return $_SESSION[$name];
584 if ( defined(
'OXID_PHP_UNIT' ) ) {
585 if ( isset( modSession::$unitMOD ) && is_object( modSession::$unitMOD ) ) {
594 $_SESSION[$name] = null;
596 unset( $_SESSION[$name] );
608 public function sid( $blForceSid =
false )
615 && is_array(
$myConfig->getConfigParam(
'aCacheViews' ) )
619 if (!$blDisableSid && $this->
getId() && ( $blForceSid || !$blUseCookies || !$this->
_getCookieSid())) {
628 $sRet .=
'stoken='.$this->getSessionChallengeToken();
641 $sSid = $sToken =
'';
643 $sSid =
"<input type=\"hidden\" name=\"".$this->getForcedName().
"\" value=\"". $this->
getId() .
"\" />";
645 if ($this->
getId()) {
646 $sToken =
"<input type=\"hidden\" name=\"stoken\" value=\"".$this->getSessionChallengeToken().
"\" />";
648 return $sToken.$sSid;
658 if ( $this->_oBasket === null ) {
663 oxNew(
'oxbasketitem');
666 $oEmptyBasket =
oxNew(
'oxbasket');
668 $oBasket = ( $sBasket && ( $oBasket = unserialize( $sBasket ) ) ) ? $oBasket : null;
670 if ( !$oBasket || ( get_class($oBasket) !== get_class($oEmptyBasket) ) ) {
671 $oBasket = $oEmptyBasket;
691 if (empty($aCurrContent)) {
696 foreach ($aCurrContent as $oContent) {
697 if ($oContent->getLanguageId() != $iCurrLang) {
698 $oContent->setLanguageId($iCurrLang);
713 $this->_oBasket = $oBasket;
745 $this->_blForceNewSession =
true;
768 if ( $sUrl && !$oConfig->isCurrentUrl( $sUrl ) ) {
770 } elseif ( $this->_blSidNeeded === null ) {
772 $this->_blSidNeeded =
false;
778 $this->_blSidNeeded =
false;
780 $this->_blSidNeeded =
true;
783 if ( $blSidNeeded = $this->
getVariable(
'blSidNeeded' ) ) {
784 $this->_blSidNeeded =
true;
787 if (!count($_COOKIE)) {
788 $this->_blSidNeeded =
true;
791 $this->
setVariable(
'blSidNeeded', $this->_blSidNeeded );
810 $blReturn = (isset($_COOKIE[$this->
getName()]) && ($_COOKIE[$this->
getName()] == $this->
getId()));
830 $sSid = $this->
sid( $blSid );
835 $aUrlParts = explode(
'#', $sUrl );
836 if ( !$oStr->preg_match(
'/(\?|&(amp;)?)sid=/i', $aUrlParts[0]) && (
false === $oStr->strpos($aUrlParts[0], $sSid))) {
837 if (!$oStr->preg_match(
'/(\?|&(amp;)?)$/', $sUrl)) {
838 $aUrlParts[0] .= ( $oStr->strstr( $aUrlParts[0],
'?' ) !==
false ?
'&' :
'?' );
840 $aUrlParts[0] .= $sSid .
'&';
842 $sUrl = join(
'#', $aUrlParts );
859 $sToken = $this->
getVar(
'_rtoken');
860 if (!$sToken && $blGenerateNew) {
861 $sToken = md5(rand() . $this->
getId());
862 $sToken = substr($sToken, 0, 8);
887 $blAllowSessionStart =
true;
893 $blAllowSessionStart =
false;
895 $blAllowSessionStart =
true;
902 !(
$myConfig->getRequestParameter( $this->getName() ) ||
$myConfig->getRequestParameter( $this->getForcedName() ) ) &&
904 $blAllowSessionStart =
false;
909 return $blAllowSessionStart;
930 $blSwapped = $this->
_checkUserAgent( $myUtilsServer->getServerVar(
'HTTP_USER_AGENT' ), $this->
getVariable(
'sessionagent' ) );
932 if (
$myConfig->getConfigParam(
'blAdodbSessionHandler' ) ) {
937 $blDisableCookieCheck =
$myConfig->getConfigParam(
'blDisableCookieCheck' );
939 if ( !$blDisableCookieCheck && $blUseCookies ) {
940 $blSwapped = $this->
_checkCookies( $myUtilsServer->getOxCookie(
'sid_key' ), $this->
getVariable(
"sessioncookieisset" ) );
963 $sAgent = $oUtils->processUserAgentInfo( $sAgent );
964 $sExistingAgent = $oUtils->processUserAgentInfo( $sExistingAgent );
966 if ( $sAgent && $sAgent !== $sExistingAgent ) {
967 if ( $sExistingAgent ) {
968 $this->_sErrorMsg =
"Different browser ({$sExistingAgent}, {$sAgent}), creating new SID...<br>";
985 $sSID = $oDb->getOne(
"select SessionID from oxsessions where SessionID = ".$oDb->quote( $this->getId() ));
989 if ( !$this->_blNewSession && (!isset( $sSID) || !$sSID)) {
991 $this->_sErrorMsg =
"Session has expired in the past and someone uses this sid to reactivate it, creating new SID...<br>";
1012 $blSessCookieSetOnce =
false;
1013 if ( is_array($aSessCookieSetOnce) && isset( $aSessCookieSetOnce[$sCurrUrl] ) ) {
1014 $blSessCookieSetOnce = $aSessCookieSetOnce[$sCurrUrl];
1018 if ( $blSessCookieSetOnce && !$sCookieSid ) {
1019 if (
$myConfig->getConfigParam(
'iDebug' ) ) {
1020 $this->_sErrorMsg =
"Cookie not found, creating new SID...<br>";
1021 $this->_sErrorMsg .=
"Cookie: $sCookieSid<br>";
1022 $this->_sErrorMsg .=
"Session: $blSessCookieSetOnce<br>";
1023 $this->_sErrorMsg .=
"URL: ".$sCurrUrl.
"<br>";
1029 if ( $sCookieSid ==
"oxid" && !$blSessCookieSetOnce ) {
1030 if (!is_array($aSessCookieSetOnce)) {
1031 $aSessCookieSetOnce = array();
1034 $aSessCookieSetOnce[$sCurrUrl] =
"ox_true";
1035 $this->
setVariable(
"sessioncookieisset", $aSessCookieSetOnce );
1039 if ( !$sCookieSid ) {
1055 if ( $sSessId && session_id() != $sSessId ) {
1056 $this->_blNewSession =
true;
1059 session_id( $sSessId );
1061 $this->
setId( $sSessId );
1066 if ( $blUseCookies ) {
1072 if ( $blUseCookies ) {
1086 if (
$myConfig->getConfigParam(
'blMallSharedBasket' ) == 0 ) {
1087 return $myConfig->getShopId().
"_basket";
1110 $aCfgArray = $this->
getConfig()->getConfigParam(
'aRequireSessionWithParams');
1111 if (is_array($aCfgArray)) {
1113 foreach ($aCfgArray as $key => $val) {
1114 if (!is_array($val) && $val) {
1115 unset($aDefault[$key]);
1118 return array_merge_recursive($aCfgArray, $aDefault);
1131 $sValue = $this->
getConfig()->getRequestParameter( $sParam );
1132 if (isset($sValue)) {
1133 if (is_array($aValues)) {
1134 if (isset($aValues[$sValue]) && $aValues[$sValue]) {
1137 } elseif ($aValues) {
1143 return ( isset( $_SERVER[
'REQUEST_METHOD'] ) && $_SERVER[
'REQUEST_METHOD'] ==
'POST');
1153 return $this->
isAdmin() || $this->
getConfig()->getConfigParam(
'blSessionUseCookies');
1163 $sInputToken = $this->
getConfig()->getRequestParameter(
'rtoken' );
1165 $blTokenEqual = !(bool)strcmp($sInputToken, $sToken);
1166 $blValid = $sInputToken && $blTokenEqual;
1178 if (!$this->_oBasketReservations) {
1179 $this->_oBasketReservations =
oxNew(
'oxBasketReservation');
1191 return headers_sent();