Sfoglia il codice sorgente

Merge branch 'master' of https://github.com/unaio/una

AntonLV 5 anni fa
parent
commit
e4c38dc320
2 ha cambiato i file con 15 aggiunte e 1 eliminazioni
  1. 10 1
      inc/classes/BxDolSession.php
  2. 5 0
      inc/classes/BxDolSessionQuery.php

+ 10 - 1
inc/classes/BxDolSession.php

@@ -80,7 +80,16 @@ class BxDolSession extends BxDolFactory implements iBxDolSingleton
 		if($this->bAutoLogout && isLogged())
 			bx_logout();
 
-        $this->sId = genRndPwd(32, true);
+		// try to restore user's old session
+		if (isLogged()) {
+		    $this->sId = $this->oDb->getOldSession(getLoggedId());
+		    if ($this->sId)
+		        $this->exists($this->sId); // it exists for sure but required for initializing some data there
+        }
+
+		// if an old session has not been found then generate a new one
+		if (!$this->sId)
+            $this->sId = genRndPwd(32, true);
 
         $aUrl = parse_url(BX_DOL_URL_ROOT);
         $sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/';

+ 5 - 0
inc/classes/BxDolSessionQuery.php

@@ -65,6 +65,11 @@ class BxDolSessionQuery extends BxDolDb
             $this->query("OPTIMIZE TABLE `" . $this->sTable . "`");
         return $iRet;
     }
+    function getOldSession($iUserId) {
+        $sSql = $this->prepare("SELECT `id` FROM `" . $this->sTable . "` WHERE `user_id`=? LIMIT 1", $iUserId);
+        $sSession = $this->getOne($sSql);
+        return !empty($sSession) ? $sSession : false;
+    }
 }
 
 /** @} */