2
0

session.class.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. class session
  3. {
  4. public static function createSession(array $_array, string $_type = "user")
  5. {
  6. $_SESSION[$_type] = $_array;
  7. }
  8. public static function getId(string $_type = "user")
  9. {
  10. return $_SESSION[$_type]["id"];
  11. }
  12. public static function getValue(string $_val, string $_type = "user")
  13. {
  14. return $_SESSION[$_type][$_val];
  15. }
  16. public static function getName(string $_type = "user")
  17. {
  18. return $_SESSION[$_type]["prenom"] . " " . $_SESSION[$_type]["nom"];
  19. }
  20. public static function getType(string $_type = "user")
  21. {
  22. return $_SESSION[$_type]["idType"];
  23. }
  24. public static function isConnect(string $_type = "user")
  25. {
  26. return (isset($_SESSION[$_type]["id"])) ? TRUE : FALSE;
  27. }
  28. public static function access(array $_type){
  29. return (in_array($_SESSION["user"]["idType"], $_type)) ? TRUE : FALSE;
  30. }
  31. public static function isEspaceControleurs(){
  32. return ($_SERVER['HTTP_HOST'] == DOMAIN_CONTROL) ? TRUE : FALSE;
  33. }
  34. public static function isEspaceSalaries(){
  35. return ($_SERVER['HTTP_HOST'] == DOMAIN_EVENTS) ? TRUE : FALSE;
  36. }
  37. }