PHP code example of ocolin / bx-auth

1. Go to this page and download the library: Download ocolin/bx-auth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ocolin / bx-auth example snippets


$auth = new \Ocolin\BxAuth\BxAuth(
    host: 'localhost',
    name: 'billmax',
    user: 'myusername',
    pass: 'mypassword'
);

$_ENV['BILLMAX_DB_HOST'] = 'localhost';
$_ENV['BILLMAX_DB_NAME'] = 'billmax';
$_ENV['BILLMAX_DB_USER'] = 'myusername';
$_ENV['BILLMAX_DB_PASS'] = 'mypassword';

$auth = new \Ocolin\BxAuth\BxAuth();

$data = $auth->login(
    user: 'bobsuncle',
    pass: 'tiddlywinks',
    session: true
);

print_r( $_SESSION );

Array
(
    [LOGGED_IN] => 1
    [AUTH] => Ocolin\BxAuth\AuthData Object
        (
            [id] => 86
            [access] => 31
            [descr] => Bob Uncle
            [email] => [email protected]
            [user] => bobsuncle
            [fname] => Bob
            [lname] => Uncle
            [password] => $1$UV$hR/8uhVeBpD5Wzb0V7Dyz/
        )

)

$auth->logout();


$loggedin = $auth->check_Login();

var_dump( $loggedin );

bool(true)