PHP Classes

PHP Login System Manager: Manage user register and login in a single script

Recommend this page to a friend!
  Info   View files Documentation   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2022-08-19 (3 months ago) RSS 2.0 feedNot enough user ratingsTotal: 272 This week: 2All time: 7,651 This week: 349Up
Version License PHP version Categories
loginmanager 1.1.1Artistic License5PHP 5, User Management
Description Author

This package can Manage user register and login in a single script.

It provides a class that implements a fluent interface of functions that applications can use to set options and callback functions to customize how the login system can work well integrated with how an application stores and retrieves user data records eventually from a database.

Currently, it provides:

- Option to set the secret salt value to hash passwords

- Callback functions to set and unset the user session or cookie tokens

- Callback function to get the user records using the user name and password

- Other useful configuration options

URL and callback functions to handle the login, logout, and priviliged access is based on the actual framework that uses LoginManager.

Innovation Award
PHP Programming Innovation award winner
July 2022
Winner
All sites that have registered users implement a system to create and manage user records and user login sessions.

This package provides a simple solution that application developers can quickly adapt to any site regardless of how it stores and retrieves the user records.

It provides a single class that applications can use to handle access to most types of pages that the applications will use to handle user registration, login, administration, etc.

Manuel Lemos
Picture of Nikos M.
Name: Nikos M. is available for providing paid consulting. Contact Nikos M. .
Classes: 17 packages by
Country: Greece Greece
Age: 46
All time rank: 9059 in Greece Greece
Week rank: 49 Up1 in Greece Greece Up
Innovation award
Innovation award
Nominee: 7x

Winner: 2x

Details

LoginManager

Simple, barebones login manager for PHP, JavaScript, Python

version 1.1.1

Login Manager

see also:

  • ModelView a simple, fast, powerful and flexible MVVM framework for JavaScript
  • tico a tiny, super-simple MVC framework for PHP
  • LoginManager a simple, barebones agnostic login manager for PHP, JavaScript, Python
  • SimpleCaptcha a simple, image-based, mathematical captcha with increasing levels of difficulty for PHP, JavaScript, Python
  • Dromeo a flexible, and powerful agnostic router for PHP, JavaScript, Python
  • PublishSubscribe a simple and flexible publish-subscribe pattern implementation for PHP, JavaScript, Python
  • Importer simple class & dependency manager and loader for PHP, JavaScript, Python
  • Contemplate a fast and versatile isomorphic template engine for PHP, JavaScript, Python
  • HtmlWidget html widgets, made as simple as possible, both client and server, both desktop and mobile, can be used as (template) plugins and/or standalone for PHP, JavaScript, Python (can be used as plugins for Contemplate)
  • Paginator simple and flexible pagination controls generator for PHP, JavaScript, Python
  • Formal a simple and versatile (Form) Data validation framework based on Rules for PHP, JavaScript, Python
  • Dialect a cross-vendor & cross-platform SQL Query Builder, based on GrammarTemplate, for PHP, JavaScript, Python
  • DialectORM an Object-Relational-Mapper (ORM) and Object-Document-Mapper (ODM), based on Dialect, for PHP, JavaScript, Python
  • Unicache a simple and flexible agnostic caching framework, supporting various platforms, for PHP, JavaScript, Python
  • Xpresion a simple and flexible eXpression parser engine (with custom functions and variables support), based on GrammarTemplate, for PHP, JavaScript, Python
  • Regex Analyzer/Composer Regular Expression Analyzer and Composer for PHP, JavaScript, Python

Example:

// setup
$lm = new LoginManager();
$lm
->option('secret_salt', 'SALT')
->option('set_token', function($name, $value, $expires) {
    // for example use HTTP cookies to store auth token
    // other option would be storing it in $_SESSION
    $_COOKIE[$name] = $value;
    setcookie(
        $name,
        $value,
        $expires,
        "",
        "",
        false,
        true
    );
})
->option('unset_token', function($name) {
    // for example use HTTP cookies to store auth token
    // other option would be storing it in $_SESSION
    unset($_COOKIE[$name]);
    setcookie(
        $name,
        "",
        0,
        "",
        "",
        false,
        true
    );
})
->option('get_token', function($name) {
    // for example use HTTP cookies to store auth token
    // other option would be storing it in $_SESSION
    return isset($_COOKIE[$name]) ? $_COOKIE[$name] : null;
})
->option('get_user', function($username, $password = false) use ($mymodel) {
    $user = false !== $password ? $mymodel->findByUserNameAndPassword($username, $password) : $mymodel->findByUserName($username);
    return empty($user) ? null : new LoginManagerUser($user->username, $user->password, $user /original user object/);
})
// optional
->option('get_guest', function() {
    return new LoginManagerUser('guest', null, (object)array('id'=>0,'username'=>'guest'));
})
;
// use it
$app->on('/login', function() use ($lm) {
    $success = $lm->login($_POST['username'], $_POST['password'], !empty($_POST['rememberme']));
    if ($success) $app->redirect('/', 302);
    else $app->output('login.tpl', ['error' => 'Invalid username or password']);
});
$app->on('/logout', function() use ($lm) {
    $lm->logout();
    $app->redirect('/', 302);
});
$app->on('/admin', function() use ($lm) {
    if (!$lm->isLoggedIn()) $app->redirect('/login');
    else $app->output('admin.tpl', ['user'=>$lm->getUser() /original user object/]);
});
  Files folder image Files  
File Role Description
Files folder imagedemo (2 files, 1 directory)
Files folder imagesrc (3 directories)
Accessible without login Image file loginmanager.jpg Icon Icon image
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  demo  
File Role Description
Files folder imageviews (4 files, 1 directory)
  Plain text file index.php Class Class source
  Accessible without login Plain text file server.php Aux. Auxiliary script

  Files folder image Files  /  demo  /  views  
File Role Description
Files folder imagelayout (1 file)
  Accessible without login Plain text file 404.tpl.php Example Example script
  Accessible without login Plain text file content.tpl.php Example Example script
  Accessible without login Plain text file index.tpl.php Example Example script
  Accessible without login Plain text file login.tpl.php Example Example script

  Files folder image Files  /  demo  /  views  /  layout  
File Role Description
  Accessible without login Plain text file base.tpl.php Example Example script

  Files folder image Files  /  src  
File Role Description
Files folder imagejs (1 file)
Files folder imagephp (1 file)
Files folder imagepython (1 file)

  Files folder image Files  /  src  /  js  
File Role Description
  Accessible without login Plain text file todo.txt Doc. Documentation

  Files folder image Files  /  src  /  php  
File Role Description
  Plain text file LoginManager.php Class Class source

  Files folder image Files  /  src  /  python  
File Role Description
  Accessible without login Plain text file todo.txt Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:272
This week:2
All time:7,651
This week:349Up
User Comments (1)
Poor OOP.
3 months ago (Cleriic)
20%StarStar