simple tokenized loginsystem
This commit is contained in:
parent
8f2311df0b
commit
f5371aba5d
5 changed files with 124 additions and 10 deletions
16
login.php
Normal file
16
login.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
if (empty($_POST) || !isset($_POST['submit'])) {
|
||||
die("Login canceled: no post / no submit");
|
||||
}
|
||||
|
||||
require_once('inc/database.php');
|
||||
$db = new DataBase();
|
||||
$user = $db->getUserByHandle($_POST['name']);
|
||||
if ($db->passwordVerify($user['user.id'], $_POST['pass'])) {
|
||||
$token = $db->tokenAdd($user['user.id']);
|
||||
$token64 = base64_encode($token);
|
||||
$expires = time() + 2592000; // 30 days
|
||||
setcookie('token', $token64, $expires);
|
||||
}
|
||||
header("Location: /");
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue