2018-02-11 20:15:28 -05:00
|
|
|
<?php
|
2018-12-21 15:25:31 -05:00
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
2018-12-21 15:25:31 -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
|
|
|
|
2018-12-21 15:25:31 -05:00
|
|
|
return self::set($param, array_merge($p, $value));
|
|
|
|
|
}
|
2018-02-11 20:15:28 -05:00
|
|
|
|
2018-12-21 15:25:31 -05:00
|
|
|
public static function get($key, $default = null)
|
|
|
|
|
{
|
|
|
|
|
return array_get($_SESSION, $key, $default);
|
|
|
|
|
}
|
2018-02-11 20:15:28 -05:00
|
|
|
|
2018-12-21 15:25:31 -05:00
|
|
|
public static function set($key, $value)
|
|
|
|
|
{
|
|
|
|
|
return array_set($_SESSION, $key, $value);
|
|
|
|
|
}
|
2018-02-11 20:15:28 -05:00
|
|
|
|
2018-12-21 15:25:31 -05:00
|
|
|
public static function forget($keys)
|
|
|
|
|
{
|
|
|
|
|
return array_forget($_SESSION, $keys);
|
|
|
|
|
}
|
2018-02-11 20:15:28 -05:00
|
|
|
|
2024-12-26 11:06:54 -05:00
|
|
|
/**
|
|
|
|
|
* Key exists and is not null
|
|
|
|
|
*
|
|
|
|
|
* @param $name
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2018-12-21 15:25:31 -05:00
|
|
|
public static function has($name): bool
|
|
|
|
|
{
|
2024-12-26 11:06:54 -05:00
|
|
|
$placeholder = new stdClass;
|
|
|
|
|
$item = array_get($_SESSION, $name, $placeholder);
|
|
|
|
|
return $item !== $placeholder;
|
2018-12-21 15:25:31 -05:00
|
|
|
}
|
|
|
|
|
|
2024-12-26 11:06:54 -05:00
|
|
|
/**
|
|
|
|
|
* Key exists
|
|
|
|
|
*
|
|
|
|
|
* @param $key
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2018-12-21 15:25:31 -05:00
|
|
|
public static function exists($key)
|
|
|
|
|
{
|
|
|
|
|
return array_has($_SESSION, $key);
|
|
|
|
|
}
|
2020-06-15 15:22:33 -04:00
|
|
|
|
|
|
|
|
public static function token()
|
|
|
|
|
{
|
|
|
|
|
return array_get($_SESSION, \Auth_UI::CSRF_KEY);
|
|
|
|
|
}
|
2018-12-21 15:25:31 -05:00
|
|
|
}
|