Added more protection against session theft

This commit is contained in:
Lukas Metzger 2016-01-29 15:39:40 +01:00
parent 8db64004ca
commit 243e9b045f
3 changed files with 14 additions and 1 deletions

View file

@ -35,6 +35,11 @@ if (password_verify($input->password, $password)) {
$_SESSION['id'] = $id;
$_SESSION['type'] = $type;
$randomSecret = base64_encode(openssl_random_pseudo_bytes(32));
$_SESSION['secret'] = $randomSecret;
setcookie("authSecret", $randomSecret, 0, "/", "", false, true);
} else {
$retval['status'] = "fail";
}

View file

@ -18,7 +18,14 @@
session_start();
if(!isset($_SESSION['id'])) {
if(
!isset($_SESSION['id']) ||
!isset($_SESSION['secret']) ||
!isset($_COOKIE['authSecret']) ||
$_SESSION['secret'] !== $_COOKIE['authSecret']
) {
header('Location: index.php');
session_destroy();
exit();
}

View file

@ -17,6 +17,7 @@ limitations under the License.
<?php
require_once 'lib/session.php';
session_destroy();
setcookie("authSecret", "", 1, "/", "", false, true);
?>
<html>
<head>