https://github.com/solutionstack/xsession
A OOPHP class to easily and securely handle sessions
https://github.com/solutionstack/xsession
object-oriented-programming php56 php7 session-management
Last synced: about 2 months ago
JSON representation
A OOPHP class to easily and securely handle sessions
- Host: GitHub
- URL: https://github.com/solutionstack/xsession
- Owner: solutionstack
- License: apache-2.0
- Created: 2017-10-01T14:05:36.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-13T04:12:30.000Z (over 7 years ago)
- Last Synced: 2025-01-20T12:05:09.907Z (11 months ago)
- Topics: object-oriented-programming, php56, php7, session-management
- Language: PHP
- Homepage:
- Size: 43 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/solutionstack/XSession)
[]()
[](https://github.com/solutionstack/XSession/issues)
# XSession
An OO-PHP class to easily handle sessions
## Requirements
- PHP 7+
## Usage
Include or autoload the XSession.php file, then use as follows..
```php
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");
```
## In other pages you need to use (check/resume) the session, just do..
```php
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
}
```
## When done with the session, say in your logout routine,..
```php
use solutionstack\XSession;
//use the same session name used in starting the session
$s = new XSession(string session_name);
$s->end();
```
### And Thats it.
### XSession uses ideas from the following project [SecureSessionHandler]
See https://gist.github.com/eddmann/10262795
License
----
Apache 2
**Free Software, Hell Yeah!**