https://github.com/tomkyle/session
PHP Session helper, extracted from my melting codebase monolith.
https://github.com/tomkyle/session
Last synced: 12 months ago
JSON representation
PHP Session helper, extracted from my melting codebase monolith.
- Host: GitHub
- URL: https://github.com/tomkyle/session
- Owner: tomkyle
- Created: 2014-03-07T17:36:44.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-12T08:53:10.000Z (over 12 years ago)
- Last Synced: 2025-06-26T08:02:51.706Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 137 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
#tomkyle/session
[](https://scrutinizer-ci.com/g/tomkyle/Session/)
A PHP Session helper that stores session data in sub-namespaces.
$_SESSION (PHP superglobal)
|
+-- SessionStorage (or derived class name)
|
+-- keyword (passed in instantiation)
|
+-- foo => bar
+-- key => value
##Example
```php
foo = "bar";
$namespace1->key = "value";
$namespace2 = new MySessionData( "user" );
$namespace2->foo = "baz";
$namespace2->key = 2000;
$namespace3 = new SessionStorage( "keyword" );
$namespace3->foo = "anything";
$namespace3->key = "something";
// will both print "bar":
echo $namespace1->foo;
// compare old-school:
echo $_SESSION['MySessionData']['keyword']['foo'];
// will both print "baz":
echo $namespace2->foo;
// compare old-school:
echo $_SESSION['MySessionData']['user']['foo'];
// will both print "not the same"
echo ($namespace1->foo == $namespace2->foo)
? "samesame" : "not the same";
echo ($namespace2->foo == $namespace3->foo)
? "samesame" : "not the same";
```