1
0

Added proper session handling while in development mode

This commit is contained in:
Christiaan Goossens 2017-03-26 15:28:33 +02:00
parent 55b8b75c0e
commit 45db7e7b93
4 changed files with 19 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/vendor/ /vendor/
/logs/* /logs/*
/tmp/

View File

@ -12,8 +12,13 @@
* Jelmer Hinssen * 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 * Check if the script is running in CLI mode

View File

@ -33,17 +33,22 @@ class Authorization
$klantnr = $rekeningen[$id]['klantid']; $klantnr = $rekeningen[$id]['klantid'];
$klant = $db->klanten->where('id', $klantnr)[$klantnr]; $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 true;
} }
return false; return false;
} }
public function getUser() public function getUserID()
{ {
return $_SESSION['user']; return $_SESSION['userid'];
}
public function isUserAuthenticated()
{
return $this->getUserID() !== null;
} }
} }

View File

@ -16,6 +16,8 @@
* BOOTSTRAPPING SCRIPT * BOOTSTRAPPING SCRIPT
*/ */
session_start();
// Get the Slim framework settings // Get the Slim framework settings
$settings = require __DIR__ . '/settings.php'; $settings = require __DIR__ . '/settings.php';