for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace System;
class Session
{
/**
* Application Object
*
* @var \System\Application
*/
private $app;
* Constructor
* @param \System\Application $app
public function __construct(Application $app)
$this->app = $app;
}
* Start session
* @return void
public function start()
ini_set('session.use_only_cookies', 1);
if (!session_id()) {
session_start();
* Set new value to session
* @param string $key
* @param mixed $value
public function set(string $key, $value)
$_SESSION[$key] = $value;
* Get value from session by the given key
* @param mixed $default
* @return mixed
public function get(string $key, $default = null)
return array_get($_SESSION, $key, $default);
* Determine if the session has the given key
* @return bool
public function has(string $key)
return isset($_SESSION[$key]);
* Remove the given key from session
public function remove(string $key)
unset($_SESSION[$key]);
* Get value from session by the given key then remove it
public function pull(string $key)
$value = $this->get($key);
$this->remove($key);
return $value;
* Get all session data
* @return array
public function all()
return $_SESSION;
* Destroy session
public function destroy()
session_destroy();
unset($_SESSION);