PHP code example of node-link / cakephp-remember-me
1. Go to this page and download the library: Download node-link/cakephp-remember-me 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/ */
node-link / cakephp-remember-me example snippets
// In src/Application.php. Requires at least 3.6.0
use Cake\Http\BaseApplication;
class Application extends BaseApplication
{
public function bootstrap()
{
parent::bootstrap();
// Load the plugin
$this->addPlugin('NodeLink/RememberMe');
}
}
// In config/bootstrap.php
use Cake\Core\Plugin;
Plugin::load('NodeLink/RememberMe', ['bootstrap' => true]);
namespace App\Controller;
use Cake\Controller\Controller;
class AppController extends Controller
{
public function initialize()
{
parent::initialize();
$this->loadComponent('Auth', [
'authenticate' => [
'Form' => [
'userModel' => 'Users',
'fields' => ['username' => 'username', 'password' => 'password'],
],
'NodeLink/RememberMe.Cookie' => [
'userModel' => 'Users', // Please set the same as 'Form'.
'fields' => ['token' => 'remember_token'], // Specify the column where you want to save the token for Remember-me authentication.
],
],
]);
// ...
}
}
namespace App\Model\Entity;
use Cake\ORM\Entity;
class User extends Entity
{
protected $_hidden = [
'password',
'remember_token', // Add
];
}