I've just bought hosting from 1and1 (german one) and I've got a problem. It seems like a session is not working in other files. When the user logs in, then nothing happens and I can see logged as: (empty) should be logged as test@mail.com. Why? The way I'm making session variables:
session_start();
$sql = "SELECT * FROM user where email = '$login'";
$result = $conn->query($sql);
$row = mysqli_fetch_array($result);
if(password_verify($password, $row["password"])) {
if (!empty($row["email"]) and !empty($row["password"])) {
$_SESSION["logged"] = $row["id"];
$_SESSION["user"] = ''.$row["email"];
header ("Location: panel.php");
}
}
Everything goes fine because the user is redirected to panel.php The way I'm calling session in navbar.php or panel.php
<?php
session_start();
if(isset($_SESSION["logged"])) echo '
<li class="nav-item"> <a class="nav-link" href="panel.php">User Panel</a> </li>
<li class="nav-item"> <a class="nav-link text-primary" href="logout.php">Logout</a></li>
';
else echo '
<li class="nav-item"> <a class="nav-link" href="login.php">Log in</a> </li>
<li class="nav-item"> <a class="nav-link text-primary" href="register.php">Register</a></li>
';
?>
On my university hosting it works as it should. Can some one advice me what to do?
Below I show phpinfo from 1and1 and my uni server: