Created
June 28, 2018 13:59
-
-
Save BAHC/2ccb24c4685abfcfce32ffa973d4cc44 to your computer and use it in GitHub Desktop.
Sessions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ICSessions | |
{ | |
static public function Init(){ | |
if (!session_id()) @session_start(); | |
return new ICSession; | |
} | |
public function Set($key='', $value='') | |
{ | |
$_result = !empty($key); | |
if ($_result) { | |
$_SESSION[$key] = $value; | |
} | |
return $_result; | |
} | |
public function Get($key) | |
{ | |
return (isset($_SESSION[$key]))? $_SESSION[$key]: null; | |
} | |
public function Unset(){ | |
if (!session_id()) session_unset(); | |
return null; | |
} | |
} | |
$session = ICSessions::Init(); | |
$session->Set('cat','Kitty'); | |
echo $session->Get('cat'); | |
$session = $session->Unset(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment