Guest User

Untitled

a guest
Jul 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2.  
  3. class Session{
  4. private static $instance;
  5.  
  6. private function __construct(){
  7. session_start();
  8. }
  9.  
  10. public static function getInstance() {
  11. if (!isset(self::$instance)) {
  12. self::$instance = new Session();
  13. }
  14. return self::$instance;
  15. }
  16.  
  17. public function setProperty( $key, $val ) {
  18. // don't need to check that session exists
  19. // since if we're here we must have instantiated
  20. // $instance and started the session
  21. $_SESSION[ $key ] = $val;
  22. }
  23.  
  24. public function getProperty( $key ) {
  25. $returnValue = "";
  26. if (isset($_SESSION[$key])) {
  27. $returnValue = $_SESSION[$key];
  28. }
  29. return $returnValue;
  30. }
  31. }
  32.  
  33. ?>
Add Comment
Please, Sign In to add comment