-
Notifications
You must be signed in to change notification settings - Fork 0
SessionContext
Matěj Bucek edited this page Mar 16, 2021
·
2 revisions
To make working with session easier, you can use our API for that.
namespace SimpleFW\Containers;
class SessionContext implements Context
{
public function __construct(){
session_start();
}
public function get($key)
{
if(isset($_SESSION[$key]))
return $_SESSION[$key];
else
return NULL;
}
public function put($key, $value)
{
$_SESSION[$key] = $value;
}
public function destroy(){
session_destroy();
}
}#[Autowired("@SessionContext")]
private SessionContext $sessionContext;You can inject the SessionContext through Attribute Autowired, or through the constructor.