2019-09-26 04:27:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace MVC\Classe;
|
|
|
|
|
|
|
|
class Session
|
|
|
|
{
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function start()
|
2019-10-11 15:26:22 +02:00
|
|
|
{
|
|
|
|
session_start();
|
|
|
|
return;
|
|
|
|
}
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function destroy()
|
2020-04-01 09:19:34 +02:00
|
|
|
{
|
|
|
|
session_destroy();
|
|
|
|
return;
|
|
|
|
}
|
2019-10-11 15:26:22 +02:00
|
|
|
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function setUserProfile($userProfile)
|
2019-10-11 15:26:22 +02:00
|
|
|
{
|
|
|
|
$_SESSION['userProfile'] = $userProfile;
|
|
|
|
return;
|
|
|
|
}
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function setId($id)
|
2020-04-01 11:40:50 +02:00
|
|
|
{
|
|
|
|
$_SESSION['id'] = $id;
|
|
|
|
return;
|
|
|
|
}
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function setUserName($username)
|
2020-04-01 11:40:50 +02:00
|
|
|
{
|
|
|
|
$_SESSION['username'] = $username;
|
|
|
|
return;
|
|
|
|
}
|
2019-10-11 15:26:22 +02:00
|
|
|
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function setToken($token)
|
2019-10-11 15:26:22 +02:00
|
|
|
{
|
|
|
|
$_SESSION['userToken'] = $token;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function setStorage($hybriauthStorage)
|
2020-03-19 16:57:14 +01:00
|
|
|
{
|
|
|
|
$_SESSION['storage'] = $hybriauthStorage;
|
|
|
|
return;
|
|
|
|
}
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function getStorage()
|
2020-03-19 16:57:14 +01:00
|
|
|
{
|
|
|
|
return $_SESSION['storage'] ;
|
|
|
|
}
|
|
|
|
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function setHybridAuth($hybriauth)
|
2020-03-19 16:57:14 +01:00
|
|
|
{
|
|
|
|
$_SESSION['auth'] = $hybriauth;
|
|
|
|
return;
|
|
|
|
}
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function getHybridAuth()
|
2020-03-19 16:57:14 +01:00
|
|
|
{
|
|
|
|
return $_SESSION['auth'] ;
|
|
|
|
}
|
|
|
|
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function isRegistered()
|
2019-09-26 04:27:05 +02:00
|
|
|
{
|
|
|
|
if (isset($_SESSION['userProfile'])) {
|
2020-04-01 09:19:34 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-09 10:26:26 +01:00
|
|
|
public static function redirectIfNotRegistered()
|
2020-04-01 09:19:34 +02:00
|
|
|
{
|
|
|
|
if (isset($_SESSION['userProfile'])) {
|
|
|
|
return ;
|
2019-09-26 04:27:05 +02:00
|
|
|
} else {
|
|
|
|
header("location : " . Url::link_rewrite(false, 'error', []));
|
|
|
|
die('Ooops, something was wrong...');
|
|
|
|
}
|
|
|
|
}
|
2020-12-09 10:26:26 +01:00
|
|
|
}
|