Fix session lock

Still needs improvment. Shouldn't be static!
This commit is contained in:
Dennis Eichhorn 2016-11-24 15:37:24 +01:00
parent baeb32b51e
commit 7b36dafa57
2 changed files with 7 additions and 10 deletions

View File

@ -85,8 +85,6 @@ class HttpSession implements SessionInterface
$this->sid = session_id(); $this->sid = session_id();
$this->setCsrfProtection(); $this->setCsrfProtection();
self::$isLocked = true;
} }
/** /**
@ -135,7 +133,7 @@ class HttpSession implements SessionInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public static function lock() public function lock()
{ {
self::$isLocked = true; self::$isLocked = true;
} }
@ -158,7 +156,10 @@ class HttpSession implements SessionInterface
*/ */
public function save() public function save()
{ {
if(!self::$isLocked) {
$_SESSION = $this->sessionData;
session_write_close();
}
} }
/** /**
@ -199,10 +200,7 @@ class HttpSession implements SessionInterface
*/ */
public function __destruct() public function __destruct()
{ {
if(!self::$isLocked) { $this->save();
$_SESSION = $this->sessionData;
session_write_close();
}
} }
} }

View File

@ -93,8 +93,7 @@ abstract class HeaderAbstract
*/ */
public static function lock() public static function lock()
{ {
CookieJar::lock(); // todo: maybe pass session as member and make lock not static
HttpSession::lock();
self::$isLocked = true; self::$isLocked = true;
} }