Skip to content

Commit

Permalink
cookie error review
Browse files Browse the repository at this point in the history
  • Loading branch information
ketertitus committed Mar 31, 2024
1 parent 76e9ce4 commit d37498f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@
'merchantid' => $row['merchant_id'],
'userid' => $row['user_id']
];
$redis->hmset("user:$me", $sessionData);
$redis->expire("user:$me", 7200);
setcookie("user_id", $me, time() + 7200, "/");
// Redirect to the home page
// header("Location: index.php");
echo '<script>window.location.href = "index.php"</script>';
exit();
try {
// Assuming $redis is your Redis connection object and $me is the user ID
$redis->hmset("user:$me", $sessionData);
$redis->expire("user:$me", 7200);
setcookie("user_id", $me, time() + 7200, "/");
// Redirect to the home page
// header("Location: index.php");
echo '<script>window.location.href = "index.php"</script>';
} catch (Exception $e) {
// Handle the error
echo "<script>alert('Error: " . $e->getMessage() . "');</script>";
}
} else {
echo "Incorrect password, please retry";
}
Expand Down

0 comments on commit d37498f

Please sign in to comment.