diff options
author | Frédéric Guillot <fred@kanboard.net> | 2017-12-06 16:19:11 -0800 |
---|---|---|
committer | Frédéric Guillot <fguillot@apple.com> | 2017-12-12 15:04:28 -0800 |
commit | ccd177ada6823c27a6408427f19c238fd701c39e (patch) | |
tree | 9846c792bd4c4f9318768f00db0e8f00cc25954b /app/functions.php | |
parent | 421531bd4f0af6a26e0b7971e23d5af1d5cf7d05 (diff) |
Store PHP sessions in the database
Diffstat (limited to 'app/functions.php')
-rw-r--r-- | app/functions.php | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/app/functions.php b/app/functions.php index 94530af8..bb739d0f 100644 --- a/app/functions.php +++ b/app/functions.php @@ -2,9 +2,50 @@ use Kanboard\Core\Translator; -function explode_csv_field($field) +function session_get($key) { - $fields = explode(',', $field); + return isset($_SESSION[$key]) ? $_SESSION[$key] : null; +} + +function session_set($key, $value) +{ + $_SESSION[$key] = $value; +} + +function session_remove($key) +{ + unset($_SESSION[$key]); +} + +function session_exists($key) +{ + return isset($_SESSION[$key]); +} + +function session_is_true($key) +{ + return isset($_SESSION[$key]) && $_SESSION[$key] === true; +} + +function session_merge($key, array $value) +{ + $_SESSION[$key] = array_merge($_SESSION[$key], $value); +} + +function session_flush() +{ + $_SESSION = []; +} + +/** + * Split CSV string + * + * @param string $str + * @return string[] + */ +function explode_csv_field($str) +{ + $fields = explode(',', $str); array_walk($fields, function (&$value) { $value = trim($value); }); return array_filter($fields); } |