Skip to content

Instantly share code, notes, and snippets.

@BAHC
Created June 28, 2018 13:59
Show Gist options
  • Save BAHC/2ccb24c4685abfcfce32ffa973d4cc44 to your computer and use it in GitHub Desktop.
Save BAHC/2ccb24c4685abfcfce32ffa973d4cc44 to your computer and use it in GitHub Desktop.
Sessions
<?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