【发布时间】:2020-04-20 14:55:15
【问题描述】:
我注意到 php 中的 cookie 会话 ID 在将您的 url 从 www 更改后发生了变化。到非 www。例如,从“https://mathtutortime.com/account”到https://www.mathtutortime.com/account”。
如果我从“https://mathtutortime.com/login”重定向到“https://www.mathtutortime.com/account”,我正在设置会话 ID:
在https://mathtutortime.com/login 我设置了一个会话变量并重定向:
$_SESSION["username"] = $username;
$_SESSION['loggedin'] = true;
header("Location: ../account");
<?php
session_start();
echo session_id();
echo " ";
if($_SESSION['loggedin'])
{
echo "You are logged in! Our site is still under construction, but it's growing quickly!<br><br>Please click one of the two buttons if you want tutoring, or if you want to be a tutor at the bottom of the screen.<br><br>";
}
?>
现在,如果我在浏览器中从“https://mathtutortime.com/account”更改为https://www.mathtutortime.com/account”,我注意到我的会话 ID 从 u5ns3nna7ntp7kbekkkk71afn6 更改为 pqrna7ntp7dsbkkkk71afn6。
我仍然能够输出消息,因为我设置了 $_SESSION['loggedin']。但是,我的问题与如果有人这样做,会话 ID 会更改这一事实有关。如果用户可以这样做,这是否会带来任何安全风险?
谢谢,
【问题讨论】:
标签: php cookies session-cookies session-variables