1. Go to this page and download the library: Download andrewlim/rememberme 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/ */
andrewlim / rememberme example snippets
// Create a RememberMeCookie and pass a PDO instance
$rememberMeCookie = new \AndrewLim\RememberMe\RememberMeCookie($pdo);
// Create a cookie, store its hash and and send it to browser
// The userid variable is a foreign key id to identify the user
$row = $rememberMeCookie->create($userid);
// Redirect to secure page
if ($row) {
header('Location: dashboard.php');
}
// If rememberme cookie is valid exists and is valid
$row = $rememberMeCookie->verify();
if ($row) {
header('Location: dashboard.php');
return;
}
// Invalid
else {
header('Location: login.php');
return;
}