我的代码有一点问题。
我试图在用户登录后在会话中存储一些变量,然后我想将用户重定向到另一个站点。我已用一些测试值替换了正确的变量,但无法弄清楚为什么这不起作用。
登录站点的代码是:
require_once ('SecureSessionHandler.class.php');
$session = new SecureSessionHandler('abcd');
$session->start();
$session->put("test", "test");
print_r($_SESSION);
if(isset($_POST['login']))
{
//check User
//login
$session->put("userlogin", 1);
header("location: index.php");
exit();
}
echo "<form action ='' method='POST'>";
echo "<label for='username'>Name: </label>";
echo "<input type='text' name='username'><br>";
echo "<label for='passwort'>Passwort: </label>";
echo "<input type='password' name='passwort'><br>";
echo "<input type='submit' name='login' value='Anmelden'>";
echo "</form>";
The print_r($_SESSION)
在这里工作得很好,它显示“Array ( [test] => test )
".
第二个站点的代码是:
<?php
require_once 'SecureSessionHandler.class.php';
$session = new SecureSessionHandler('abcd');
$session->start();
//some stuff that is not relevant here
//check login
$userlogin = $session->get('userlogin');
print_r($_SESSION);
echo "<br>";
if($userlogin == 1)
{
//do stuff
}
这里的print_r($_SESSION)
显示“Array ( )
".
我不知道为什么会这样。
我真的很感激你们能给我的任何帮助。
Okay,
所以我不知道为什么现在它按预期运行。
我的管理员让我做了一些安全更新和硬件重启,然后它就可以与标准 php 会话函数和我的 SecureSessionHandler 函数一起使用。
我想有些东西已经崩溃或阻止了对所需文件的访问。
但无论如何,还是感谢您的帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)