partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 10a95614326f1f50e74af6e8c7a4690a7f0625a4
parent 2426c895402709355c2e123e1b1303fe7e0e5bba
Author: Felicitus <felicitus@felicitus.org>
Date:   Wed, 29 Jun 2011 20:34:45 +0200

*Felicitus kicks PHP session handling in the nuts*

Clearing the session completely now. Hopefully this works well now.

Diffstat:
Msrc/de/RaumZeitLabor/PartKeepr/Auth/AuthService.php | 2--
Msrc/de/RaumZeitLabor/PartKeepr/Session/Session.php | 3+++
Msrc/de/RaumZeitLabor/PartKeepr/Session/SessionManager.php | 23+++++++----------------
3 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/src/de/RaumZeitLabor/PartKeepr/Auth/AuthService.php b/src/de/RaumZeitLabor/PartKeepr/Auth/AuthService.php @@ -28,8 +28,6 @@ class AuthService extends AnonService { if ($authenticatedUser !== false) { /* Start Session */ - SessionManager::getInstance()->invalidateSession(); - $session = SessionManager::getInstance()->startSession($authenticatedUser); return array("sessionid" => $session->getSessionID(), "username" => $this->getParameter("username"), "admin" => $session->getUser()->isAdmin()); diff --git a/src/de/RaumZeitLabor/PartKeepr/Session/Session.php b/src/de/RaumZeitLabor/PartKeepr/Session/Session.php @@ -25,7 +25,10 @@ class Session { } public function start () { + session_start(); session_regenerate_id(); + session_destroy(); + unset($_SESSION); session_start(); $this->sessionid = session_id(); diff --git a/src/de/RaumZeitLabor/PartKeepr/Session/SessionManager.php b/src/de/RaumZeitLabor/PartKeepr/Session/SessionManager.php @@ -14,26 +14,15 @@ class SessionManager extends Singleton { return self::$currentSession; } - /** - * Invalidates the given session. - * @param string $sessionid The session id - */ - public function invalidateSession () { - $query = PartKeepr::getEM()->createQuery("DELETE FROM de\RaumZeitLabor\PartKeepr\Session\Session s WHERE s.sessionid = :sessionid"); - $query->setParameter("sessionid", session_id()); - - $query->execute(); - } - public function startSession (User $user = null) { if (is_object($user)) { try { - $query = PartKeepr::getEM()->createQuery("SELECT s FROM de\\RaumZeitLabor\\PartKeepr\\Session\\Session s WHERE s.user = :user"); - $query->setParameter("user", $user); - $query->execute(); + $query = PartKeepr::getEM()->createQuery("SELECT s FROM de\\RaumZeitLabor\\PartKeepr\\Session\\Session s WHERE s.user = :user"); + $query->setParameter("user", $user); + $query->execute(); - $session = $query->getSingleResult(); - $session->resume(); + $session = $query->getSingleResult(); + $session->resume(); } catch (\Exception $e) { $session = new Session; $session->setUser($user); @@ -47,6 +36,8 @@ class SessionManager extends Singleton { PartKeepr::getEM()->persist($session); } + PartKeepr::getEM()->flush(); + self::$currentSession = $session; return $session;