Created
September 24, 2017 13:00
-
-
Save isu3ru/1de10d40a75811dd8e4b71947f5b9006 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
function setFlashDataItem($key, $value) | |
{ | |
if (!array_key_exists('flashdata', $_SESSION)) { | |
$_SESSION["flashdata"] = array(); | |
} | |
$_SESSION["flashdata"][$key] = $value; | |
} | |
function removeFlashDataItem($key) | |
{ | |
if (!array_key_exists('flashdata', $_SESSION)) { | |
return FALSE; | |
} | |
if (array_key_exists($key, $_SESSION["flashdata"])) { | |
unset($_SESSION["flashdata"][$key]); | |
} | |
} | |
function clearFlashData() | |
{ | |
//removing the outer element removes all flash data key-value pairs inside the array | |
$_SESSION["flashdata"] = array(); | |
} | |
function hasFlashDataItem($key) | |
{ | |
if (!array_key_exists('flashdata', $_SESSION)) { | |
return FALSE; | |
} | |
return array_key_exists($key, $_SESSION["flashdata"]); | |
} | |
function getFlashDataItem($key) | |
{ | |
if (!array_key_exists('flashdata', $_SESSION)) { | |
return FALSE; | |
} | |
return array_key_exists($key, $_SESSION["flashdata"]) ? $_SESSION["flashdata"][$key] : FALSE; | |
} | |
function getFlashData() | |
{ | |
if (!array_key_exists('flashdata', $_SESSION)) { | |
return FALSE; | |
} | |
return $_SESSION["flashdata"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment