I want my users to be logged out automatically after30 minutes of inactivity. I also want to have all sessions destroyed.
This is my login.php i have set cookies but does not work.
if (isset($_POST['member_login'])) {
$username = isset($_POST['username']) ? $_POST['username'] : "";
$password = md5(isset($_POST['password']) ? $_POST['password'] : "");
if (isset($_POST['keep_login'])) {
setcookie("user", $username, time() + (86400 * 30), "/");
setcookie("pass", $_POST['password'], time() + (86400 * 30), "/");
} else {
setcookie("user","", time() - (86400 * 30), "/");
setcookie("pass","", time() - (86400 * 30), "/");
}
<form class="form-horizontal" action="" name="login_form" id="login_form" method="post">
<div class="form-group mt-3">
<h5 class="mlm">Enter User Id / Email Id</h5> <input type="text" class="form-control" name="username" id="username" data-validetta="required" value="<?php if (isset($_COOKIE['user'])) { echo $_COOKIE['user']; } ?>">
</div>
<div class="form-group">
<h5 class="mlm">Enter your password</h5>
<input type="password" class="form-control" name="password" id="password" data-validetta="required" value="<?php if (isset($_COOKIE['pass'])) { echo $_COOKIE['pass']; } ?>">
</div>
<div class="row">
<div class="col-6"><label class="bis-mark mt-1">
<input type="checkbox" name="keep_login" <?php
if (isset($_COOKIE['pass']) && isset($_COOKIE['user'])) {
echo "checked";
}
?> checked>