So I have a login page on my website, which works perfectly on my computer, both Safari and Chrome, but on my iPhone, it does not work. I tried testing some code to see what is wrong, and sessions are not working in Safari. What I'm doing is once they log in, their session is $_SESSION['logged'] = true;
and get redirected to the account page. I am accepting cookies. Any help is appreciated. Thanks
<?php
session_start();
$db = mysqli_connect(#,#,#,#);
if (isset($_POST['submit'])) {
$username = mysqli_real_escape_string($db, $_POST['username']);
$password = mysqli_real_escape_string($db, $_POST['password']);
$sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$result = mysqli_query($db, $sql);
if (mysqli_num_rows($result) == 1) {
$_SESSION['username'] = $username;
$_SESSION['logged'] = true;
echo '<script type="text/javascript">
window.location = "http://example.com/index.php?page=account"
</script>';
} else {
echo '<script>';
echo "Alert.render('Incorrect Username or Password.');";
echo '</script>';
}
}
?>