PHP code example of crecket / advanced-login-script
1. Go to this page and download the library: Download crecket/advanced-login-script 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/ */
crecket / advanced-login-script example snippets
$login = new Crecket\AdvancedLogin\Login(); // call the class
define('LOGINSCRIPT_USER_ALREADY_LOGGED_IN', ''); // disable the 'already logged in message' like this
if (Crecket\AdvancedLogin\Core::$loggedIn !== false) {
// Logged in
}
// Also, if a user is logged in. The session will be stored in $_SESSION['currentuser']
if(isset($_POST['somedata']){
if(\SecureFuncs\SecureFuncs::getFormToken('updatedata'.$_POST['userid'], $_POST['formtoken'])){
// valid submission
}else{
// $_POST['formtoken'] has a different value than the original one that was sent with the form data
}
}
$userid = 59348534;
$formtoken = \SecureFuncs\SecureFuncs::setToken('updatedata'.$userid);
$loginScript->logout();
// Create a QR code on your device
$login->createQrCode(true); // Returns a PNG image + headers
$login->createQrCode(); // Returns a array with the ID, Code and Image, you'll need to generate the QR code yourself
// Verify this with a QR code reader, you'll need to be logged in to the website in order to activate the code
if ($login->verifyQrCode(@$_GET['code'])) {
echo "Activated!";
} else {
echo "Not Activated!";
}
// checkLoggedIn() will verify the QR code, it is automatically run atleast once when you create the Login class
$login = new Crecket\AdvancedLogin\Login();
// Or run the following
$login->checkLoggedIn();
Crecket\AdvancedLogin\Jwt::getCurrentUser(); // Returns the token if it exists
$login->refreshJWTtoken();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.