2017 © Pedro Peláez
 

library phpsession

Free PHP session tools for neat and powerful projects!

image

miladrahimi/phpsession

Free PHP session tools for neat and powerful projects!

  • Sunday, July 26, 2015
  • by miladrahimi
  • Repository
  • 2 Watchers
  • 3 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

PHPSession

Free PHP session tools for neat and powerful projects!, (*1)

Documentation

PHPSession is a tiny package for using sessions in Object Oriented and more secured approach. There is a class named Session which you interact with to access an manipulate sessions., (*2)

Installation

Using Composer

It's strongly recommended to use Composer to add PHPSession to your application. If you are not familiar with Composer, The article How to use composer in php projects can be useful. After installing Composer, go to your project directory and run following command there:, (*3)

composer require miladrahimi/phpsession

Or if you have composer.json file already in your application, you may add this package to your application requirements and update your dependencies:, (*4)

"require": {
    "miladrahimi/phpsession": "~1.6"
}
composer update


#### Manually
You can use your own autoloader as long as it follows [PSR-0](http://www.php-fig.org/psr/psr-0) or
[PSR-4](http://www.php-fig.org/psr/psr-4) standards.
In this case you can put `src` directory content in your vendor directory.

### Getting Started
It's so easy to work with!
use MiladRahimi\PHPSession\Session; $session = new Session(); $session->set("Singer", "Pink Floyd"); echo $session->get("Singer");

* Because of being compatible with dependency injection, new version is not based on Single Pattern. * The `get()` method will return `null` whenever the value doesn't exist. ### Expiration In default, the session data is permanent. For security reasons, you should define lifetime for your session. PHPSession would expire the data when their lifetime had finished.
use MiladRahimi\PHPSession\Session; $session = new Session(); $session->setLifeTime(10); // 10 minutes lifetime! $session->set("Singer", "Bon Jovi");
*   Lifetime unit is minute.
*   0 minute lifetime means unlimited time (it's default value).
*   Whenever you change lifetime its lifetime starts to get spent.

### UntrustedSession Exception
For security reasons, PHPSession holds user IP and Agent (web browser tool).
It always check this info in any `get()` call to make sure current user is the real session owner.
`UntrustedSession` exception will thrown if the user is suspicious.
use MiladRahimi\PHPSession\Session; use MiladRahimi\PHPSession\UntrustedSession; $session = new Session(); $session->set("Singer", "Selena Gomez"); try { echo $session->get("Singer"); } catch (UntrustedSession $e) { echo "You must sign in again!"; // Log the information... }

### Refresh PHPSession cannot recognize where exactly need to refresh the user info like IP and agent. To prevent Fixation Session Attack you should refresh sessions every successful sign in request.
$session->refresh();

Session Hijacking and Fixation

PHPSessions is tiny package right now. It will be better next versions, I promise! There are some security considerations in this version. It prevent Session Fixation if you call refresh() method after every successful sing in. It prevent simple hijackings with holding user info (IP and agent). In person, I think it's user job to prevent other threats. But your a able to implement your security approaches with PHPSession, if you see it like PHP native APIs. If you have an idea to make PHPSession more secure, I will appreciate it if you share it with us!, (*5)

Contributors

Homepage

License

PHPSession is released under the MIT License., (*6)

The Versions

26/07 2015

dev-master

9999999-dev http://miladrahimi.github.io/phpsession

Free PHP session tools for neat and powerful projects!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

security session sessions session security

26/07 2015

1.6

1.6.0.0 http://miladrahimi.github.io/phpsession

Free PHP session tools for neat and powerful projects!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

security session sessions session security

26/07 2015

1.5

1.5.0.0 http://miladrahimi.github.io/phpsession

Free PHP session tools for neat and powerful projects!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

security session sessions session security

26/07 2015

v1.3

1.3.0.0 http://miladrahimi.github.io/phpsession

Free PHP session tools for neat and powerful projects!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

security session sessions session security

12/07 2015

v1.4

1.4.0.0 http://miladrahimi.github.io/phpsession

Free PHP session tools for neat and powerful projects!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

security session sessions session security

10/07 2015

v1.2

1.2.0.0 http://miladrahimi.github.io/phpsession

Free PHP session tools for neat and powerful projects!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

security session sessions session security

10/07 2015

v1.1

1.1.0.0 http://miladrahimi.github.io/phpsession

Free PHP session tools for neat and powerful projects!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

security session sessions session security

16/06 2015

v1.0

1.0.0.0 http://phpsession.neatplex.com

Free PHP session tools for neat and powerful projects!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

security session sessions session security

15/06 2015

v0.0

0.0.0.0 http://phpsession.neatplex.com

Free PHP session tools for neat and powerful projects!

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

security session sessions session security