tigo / login-session
login using the session feature
Fund package maintenance!
www.paypal.com/donate?hosted_button_id=6QVW2XQEATS3U
www.paypal.com/donate?hosted_button_id=7GRD56DFDZWR4
Requires
- php: >= 7.2
README
Creating session for login in PHP
- MIT license. Feel free to use this project. Leave a star ⭐ !
- Download package:
composer require tigo/login-session
If you found this project useful, consider making a donation to support the developer.
Introduction
Somewhere in your project, you may need to use autoload
include __DIR__ ."/vendor/autoload.php";
Example
- Configuration:
In the src/config/Standard.php directory
- In the Standard class there is a method called postLogin(), it is through it that you will implement your logic.
- By default the postLogin() method has an implemented logic which receives data from an array, to perform post validation
// the function must return a boolean value. public function postLogin() { $user = isset($_POST[self::USER]) ? $_POST[self::USER] : false; $pw = isset($_POST[self::PW]) ? md5($_POST[self::PW]) : false; $table = TestMatrix::table(); foreach ($table as $key => $item) { if($user == $item->user && $pw == $item->password){ $_SESSION[self::SESSION] = $_POST[self::USER]; return true; } } return false; }
Method TestMatrix::table()
public static function table() { return [ 1=> (object) ["user"=>"admin","password"=>md5("123")], 2=> (object) ["user"=>"admin2","password"=>md5("1234")], 3=> (object) ["user"=>"admin3","password"=>md5("12345")] ]; }
Example methods
use Tigo\LoginSession\Login; // import class $login = new Login(); $login->validate();
Problems
If you discover any issues, please contact my email or issue tracker and post the details.
Contributors
License
MIT license. See the archive License