PHPackages                             crecket/advanced-login-script - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. crecket/advanced-login-script

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

crecket/advanced-login-script
=============================

More advanced login script with more features

1.5.2(9y ago)01291WTFPLPHPPHP &gt;=5.5.0

Since Jan 12Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Crecket/advanced-login-script)[ Packagist](https://packagist.org/packages/crecket/advanced-login-script)[ Docs](https://github.com/Crecket/advanced-login-script)[ RSS](/packages/crecket-advanced-login-script/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (5)Versions (22)Used By (0)

advanced-login-script
=====================

[](#advanced-login-script)

[![License](https://camo.githubusercontent.com/059c68da92fecac5db03627c6b13495cd6b70f9d2525971720cf335e7675c446/68747470733a2f2f706f7365722e707567782e6f72672f637265636b65742f616476616e6365642d6c6f67696e2d7363726970742f6c6963656e7365)](https://packagist.org/packages/crecket/advanced-login-script)

Introduction
------------

[](#introduction)

Advanced-login-script features a bunch of basic and more advanced options to manage your users.

Features
--------

[](#features)

1. Login/Registration
2. Usergroups and session control
3. SMTP mails over ssl
4. QRCode login
5. Config file to manage settings

Requirements
------------

[](#requirements)

1. Php version &gt;= 5.5
2. PHPMailer
3. crecket/secure-functions
4. doctrine/dbal
5. endroid/qrcode
6. firebase/php-jwt

Installation
------------

[](#installation)

#### Composer

[](#composer)

1. Require the repo `composer require crecket/advanced-login-script`
2. Copy the config file from `/vendor/crecket/advanced-login-script/src/configfiles/config.php` and place it somewhere else. (If you don't do this, updating this plugin with composer will reset your config!
3. Call the class and add config location in the first parameter

```
require_once '/config/config.php'; // include the config file
$login = new Crecket\AdvancedLogin\Login(); // call the class
```

##### Config setup

[](#config-setup)

For both composer and manual installation you have to setup the config file. Make sure to update your secret key and to change any settings. This can be done manually by editing the config file or the setConfig function. For a example view setup\_file.php in the demo folder. Once you've created a new key make sure it stays the same or all old cookies will become invalid.

For the activation link and resetpassword link {code} will get replaced with the appropriate reset code If you want to use a clean URL simply change it to something like this:

`http://localhost.dev/forgot_password/{code}`

or a normal URL could be something like this:

`http://localhost.dev/forgot_password.php?code={code}`

##### Notifications

[](#notifications)

If you wish to disable or change a notification you can do so by editing the loginScriptTranslations.php file. If you wish to disable the message all together and handle the message systme yourself, simply remove the message.

```
define('LOGINSCRIPT_USER_ALREADY_LOGGED_IN', ''); // disable the 'already logged in message' like this
```

##### Database setup

[](#database-setup)

Run the sql file includded with the project files function. In total, 5 tables will be created

- Users The basic userinfo is stored in here
- Usergroups All usergroups
- Qr\_activation Qr\_activation codes are stored in here, this will be empty for the most part since they are only valid for 30 seconds
- Login\_attempts Login attempts, the type will show how the user activated a session or if someone entered a invalid password
- User\_auth
    Remember\_me cookie values

Examples
--------

[](#examples)

#### Log in a user through login form

[](#log-in-a-user-through-login-form)

```
$loginScript->login($_POST['username'], $_POST['password'], $_POST['remember_me']);
```

#### Verify if user is logged in

[](#verify-if-user-is-logged-in)

```
if (Crecket\AdvancedLogin\Core::$loggedIn !== false) {
    // Logged in
}
// Also, if a user is logged in. The session will be stored in $_SESSION['currentuser']
```

#### Register a new user

[](#register-a-new-user)

```
$loginScript->register($username, $email, $password, $repeat_password);
```

#### Secure a form with a token

[](#secure-a-form-with-a-token)

```
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);
?>
