我在使用https协议登录网站管理时出现问题。如果我登录,它会写我的错误消息“你不被允许。回到登录页面”。哪里应该有问题?它正在http协议正常工作:-(感谢您的帮助!
index.php登录
<?php
include_once "../inc/connection.php";
if(isset($_POST['go'])){
$usr = mysqli_real_escape_string($conn, htmlentities($_POST['u_name']));
$psw = SHA1($_POST['u_pass']) ; //using SHA1() to encrypt passwords
$q = "SELECT * FROM users WHERE username='$usr' AND password='$psw'";
$res = mysqli_query($conn, $q);
if(mysqli_num_rows($res) == 1){
session_start();
$_SESSION['log'] = 'in';
header('location:photos.php');
} else {
$error = 'Wrong details. Please try again';
}
}
?>
和photos.php
<?php
session_start();
if( !isset($_SESSION['log']) || ($_SESSION['log'] != 'in') ){
echo "You are not allowed. <a href='index.php'>back to login page</a>";
exit();
}
if(isset($_GET['log']) && ($_GET['log']=='out')){
session_destroy();
header('location:index.php');
}
?>
答案 0 :(得分:0)
我认为会话路径不可写。 尝试
assets://myfile.txt