Guest User

Untitled

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