This repository has been archived on 2025-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
szurubooru/src/Helpers/SessionHelper.php
2014-05-18 21:32:47 +02:00

32 lines
649 B
PHP

<?php
class SessionHelper
{
public static function init()
{
session_start();
register_shutdown_function(function()
{
if (\Chibi\Util\Headers::getRequestMethod() == 'GET')
$_SESSION['last-visited-url'] = Core::getContext()->query;
});
}
public static function get($key, $default = null)
{
if (!isset($_SESSION[$key]))
return $default;
return $_SESSION[$key];
}
public static function set($key, $value)
{
$_SESSION[$key] = $value;
}
public static function getLastVisitedUrl()
{
if (!isset($_SESSION['last-visited-url']))
return '';
return \Chibi\Util\Url::makeAbsolute($_SESSION['last-visited-url']);
}
}