Skip to content

Commit

Permalink
add user agent to session for additional security
Browse files Browse the repository at this point in the history
(I know it's easily fakeable, but I can live with that)
  • Loading branch information
chregu committed Feb 22, 2011
1 parent d3dd5da commit af3456c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion web/Users.php
Expand Up @@ -59,6 +59,7 @@ function startSession() {
function doLogin() {
session_regenerate_id();
$_SESSION['loggedin'] = true;
$_SESSION['ua'] = $_SERVER['HTTP_USER_AGENT'];
}

function doOTP() {
Expand All @@ -74,7 +75,9 @@ function isOTP() {

}
function isLoggedIn() {
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true &&
isset($_SESSION['ua']) && $_SESSION['ua'] == $_SERVER['HTTP_USER_AGENT']
) {

return $_SESSION['username'];
}
Expand Down

0 comments on commit af3456c

Please sign in to comment.