added 'remember me option'

This commit is contained in:
Louis Vallat 2019-11-12 00:07:28 +01:00
parent efba13e55c
commit d7556a9edb
2 changed files with 6 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
$SESSION_COOKIE_NAME = "connection_id"; $SESSION_COOKIE_NAME = "connection_id";
$MAX_COOKIE_LIFE = time() + 86400 * 30; // 30 days max $MAX_COOKIE_LIFE = 86400 * 30; // 30 days max
$MINIMAL_PASSWORD_LENGTH = 8; $MINIMAL_PASSWORD_LENGTH = 8;
$config_array = json_decode(file_get_contents("config.json", true)); $config_array = json_decode(file_get_contents("config.json", true));

View File

@ -35,7 +35,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (get_username_count($username) == 1) { if (get_username_count($username) == 1) {
if (correct_email_password($username, $password)) { if (correct_email_password($username, $password)) {
if (is_https()) { if (is_https()) {
connect_user(get_user_id_from_email($username), false); connect_user(get_user_id_from_email($username), isset($_POST["stay_loggedin"]));
// Redirect user to welcome page // Redirect user to welcome page
header("location: welcome.php"); header("location: welcome.php");
@ -86,6 +86,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
<input type="password" name="password" class="form-control"> <input type="password" name="password" class="form-control">
<span class="help-block"><?php echo $password_err; ?></span> <span class="help-block"><?php echo $password_err; ?></span>
</div> </div>
<div>
<label>Remember me</label>
<input type="checkbox" name="stay_loggedin"/>
</div>
<div class="form-group"> <div class="form-group">
<input type="submit" class="btn btn-primary" value="Login"> <input type="submit" class="btn btn-primary" value="Login">
</div> </div>