Files

69 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2018-02-11 20:15:28 -05:00
<?php
/**
* Copyright (C) Apis Networks, Inc - All Rights Reserved.
*
* Unauthorized copying of this file, via any medium, is
* strictly prohibited without consent. Any dissemination of
* material herein is prohibited.
*
* For licensing inquiries email <licensing@apisnetworks.com>
*
* Written by Matt Saladna <matt@apisnetworks.com>, May 2017
*/
2018-02-11 20:15:28 -05:00
/**
* Session helper
*/
class Session
{
public static function append($param, $value)
{
$p = (array)self::get($param);
2018-02-11 20:15:28 -05:00
return self::set($param, array_merge($p, $value));
}
2018-02-11 20:15:28 -05:00
public static function get($key, $default = null)
{
return array_get($_SESSION, $key, $default);
}
2018-02-11 20:15:28 -05:00
public static function set($key, $value)
{
return array_set($_SESSION, $key, $value);
}
2018-02-11 20:15:28 -05:00
public static function forget($keys)
{
return array_forget($_SESSION, $keys);
}
2018-02-11 20:15:28 -05:00
/**
* Key exists and is not null
*
* @param $name
* @return bool
*/
public static function has($name): bool
{
$placeholder = new stdClass;
$item = array_get($_SESSION, $name, $placeholder);
return $item !== $placeholder;
}
/**
* Key exists
*
* @param $key
* @return bool
*/
public static function exists($key)
{
return array_has($_SESSION, $key);
}
public static function token()
{
return array_get($_SESSION, \Auth_UI::CSRF_KEY);
}
}