dogoda/sessions

There is no license information available for the latest version (dev-master) of this package.

A non-blocking session manager

dev-master 2020-11-18 22:43 UTC

This package is auto-updated.

Last update: 2024-11-19 09:38:59 UTC


README

A non-blocking session handler for PHP

Quick Examples

$session = new \Dogoda\Sessions\SessionInstance("my-app");
$session->set("current-status", 4);
$currentStatus = $session->get("current-status");
$session->exists("current-status"); #true

Avoid common key clashes:

$session->set("user", "Mark");

$backend = $session->createNamespace("backend");
$backend->set("user", "Caroline");

$session->get("user"); # "Mark"
$backend->get("user"); # "Caroline"

Store one-time flash messages:

$session->setFlash("message", "Your profile has been updated");

$session->getFlash("message"); # "Your profile has been updated";

$session->getFlash("message"); # null;

There is also a static class you can use with all the features above:

use \Dogoda\Sessions\Session;
Session::name("my-apps");

Session::set("current-status", 4);
$currentStatus = Session::get("current-status");

$session::set("user", "Mark");
$session::exits("user"); #true
$session::exits("password"); #false
$backend = $session::createNamespace("backend");
$backend::set("user", "Caroline");

$session::get("user"); # "Mark"
$backend::get("user"); # "Caroline"

Inspired by duncan3dc/sessions