An OO-PHP class to easily handle sessions
- PHP 7+
Include or autoload the XSession.php file, then use as follows..
use solutionstack\XSession;
//create A session
$s = new XSession(string session_name, int session_lifetime_in_secs);
//add session data as needed
$s->put("foo", "bar"):
$s->put("user_email", "mail@example.com");
use solutionstack\XSession;
//use the same session name used in starting the session
$s = new XSession(string session_name);
if($s->resume()) { //check if session was succesfully resumed
//do stuff for authenticated users
//also get previously set session values, or set new one
$email = $s->get("user_email");
}
else{
//session didn't resume succesfully, logout or do other stuff
}
use solutionstack\XSession;
//use the same session name used in starting the session
$s = new XSession(string session_name);
$s->end();
See https://gist.github.com/eddmann/10262795
Apache 2
Free Software, Hell Yeah!