2017 © Pedro Peláez
 

library session

Session Class

image

rcastera/session

Session Class

  • Wednesday, December 24, 2014
  • by rcastera
  • Repository
  • 2 Watchers
  • 18 Stars
  • 1,271 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 12 Forks
  • 2 Open issues
  • 3 Versions
  • 2 % Grown

The README.md

Session Class

This is a Session class for you guessed it, managing sessions. Back in the day, when there weren't many open source frameworks on the market, developers had to code things from scratch to achieve certain functionality. This class's inception, is the from one of those instances. With this class you can easily time-out your authenticated users after a specified interval., (*1)

### Setup

Add a composer.json file to your project:, (*2)

{
  "require": {
      "rcastera/session": "v1.0.0"
  }
}

Then provided you have composer installed, you can run the following command:, (*3)

$ composer.phar install

That will fetch the library and its dependencies inside your vendor folder. Then you can add the following to your .php files in order to use the library (if you don't already have one)., (*4)

require 'vendor/autoload.php';

Then you need to use the relevant class, and instantiate the class. For example:, (*5)

### Getting Started

require 'vendor/autoload.php';

use rcastera\Browser\Session\Session;

$session = new Session();

### Examples

Logging in. (login.php)
 1,
                'username' => $_POST['username']
            );

            $session->register(120); // Register for 2 hours.
            $session->set('current_user', $user);
            header('location: index.php');
            exit;
        } else {
            $errors[] = 'Invalid login.';
        }
    }
?>

// Your form here.
Secure area once authenticated. (index.php/controller/whatever)
isRegistered()) {
        // Check to see if the session has expired.
        // If it has, end the session and redirect to login.
        if ($session->isExpired()) {
            $session->end();
            header('location: login.php');
            exit;
        } else {
            // Keep renewing the session as long as they keep taking action.
            $session->renew();
        }
    } else {
        header('location: login.php');
        exit;
    }
?>
Logging out. (logout.php)
end();
    header('location: login.php');
    exit;
?>

### Contributing

  1. Fork it.
  2. Create a branch (git checkout -b my_branch)
  3. Commit your changes (git commit -am "Added something")
  4. Push to the branch (git push origin my_branch)
  5. Create an Issue with a link to your branch
  6. Enjoy a refreshing Coke and wait

The Versions

24/12 2014

dev-master

9999999-dev http://www.richardcastera.com

Session Class

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Richard Castera

php session

24/12 2014

v1.0.1

1.0.1.0 http://www.richardcastera.com

Session Class

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Richard Castera

php session

28/09 2013

v1.0.0

1.0.0.0 http://www.richardcastera.com

Session Class

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Richard Castera

php session