diff --git a/.gitignore b/.gitignore index cd7aa82..6a6350a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /vendor/ /logs/* +/tmp/ diff --git a/public/index.php b/public/index.php index 49d2a47..dd821e3 100644 --- a/public/index.php +++ b/public/index.php @@ -12,8 +12,13 @@ * Jelmer Hinssen */ - // Create session - session_start(); +/** + * Session fix for development + */ + +if (session_save_path() === "") { + ini_set('session.save_path', realpath(__DIR__ . '/../tmp')); +} /** * Check if the script is running in CLI mode diff --git a/src/Application/Auth/Authorization.php b/src/Application/Auth/Authorization.php index 34b36d0..2c979fc 100644 --- a/src/Application/Auth/Authorization.php +++ b/src/Application/Auth/Authorization.php @@ -33,17 +33,22 @@ class Authorization $klantnr = $rekeningen[$id]['klantid']; $klant = $db->klanten->where('id', $klantnr)[$klantnr]; - if ($klant['code'] === $passcode) { - $_SESSION['user'] = $klant; + if ($klant['code'] === $passcode) { + $_SESSION['userid'] = $klant['id']; return true; } return false; } - public function getUser() + public function getUserID() + { + return $_SESSION['userid']; + } + + public function isUserAuthenticated() { - return $_SESSION['user']; + return $this->getUserID() !== null; } } diff --git a/src/bootstrap.php b/src/bootstrap.php index ae25891..fee2e5a 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -16,6 +16,8 @@ * BOOTSTRAPPING SCRIPT */ +session_start(); + // Get the Slim framework settings $settings = require __DIR__ . '/settings.php';