doujiu9172 2013-02-23 19:28
浏览 44

似乎我的一个会话甚至没有在整个页面中保存

This is where the code begins to fail (fun.php): It also seems that the text file isn't being written to, it doesn't even create the file

<?php 
    session_start();

    if($_SESSION['LoggedIn'] == False)
    {
        header("Location: /login.php");
        return ;
    }
    include ('/home/manseld/public_html/scripts/config.php');

    if(($_SESSION['Banned'] == True && (!file_exists("/home/manseld/public_html/accounts/banned/". $_SESSION['CurrentUser'] .".txt"))))
    {
        $_SESSION['Banned'] = False;
    }

    if(file_exists("/home/manseld/public_html/accounts/banned/". $_SESSION['CurrentUser'] .".txt"))
    {
        header("Location: /error.php?e=banned&img=fuuu");
        return ;
    }
// Log User(s) IP 

    if(($_SESSION['LoggedIn'] == True) && (!$_SESSION['CurrentUser'] == "ManselD"))
    {
        ini_set('date.timezone', 'Europe/London');
        $ip = $_SERVER['REMOTE_ADDR'];
        $user = $_SESSION['CurrentUser'];
        $txt = date("h:i") ." | ". $user ." | ". $ip ."
";
        $url = "accounts/logs/". trim(date(F) ."-". date(d) ."-". date(Y) .".txt");
        $file = fopen($url, "a");
        fwrite($file, $txt);
        fclose($file);
    }
?>

Now, this is where $_SESSION['CurrentUser']; Is set (In login.php) Or in this case, not set >.>

session_start();
$user = stripslashes($_POST['user']);
$pass = stripslashes($_POST['pass']);
$banned = "/home/manseld/public_html/accounts/banned/$user.txt";
$normal = "/home/manseld/public_html/accounts/$user.txt";
$_SESSION['CurrentUser'] = "$user";

if($_SESSION['LoggedIn'] == True){
header("Location: /fun.php");
return;
}else{
$_SESSION['LoggedIn'] = False;
}

if(isset($_POST['submit'])){
// Banned Users
if(($_SESSION['Banned'] == True && (!file_exists("/home/manseld/public_html/accounts/banned/".$_SESSION['CurrentUser'].".txt")))){
$_SESSION['Banned'] = False;
}
if(file_exists("/home/manseld/public_html/accounts/banned/".$_SESSION['CurrentUser'].".txt")){
$_SESSION['Banned'] = True;
header("Location: /error.php?e=banned&img=fuuu");
return;
}else{
$_SESSION['Banned'] = False;
}

I don't really think that it should be happening, it's pretty odd. Any ideas?

  • 写回答

1条回答 默认 最新

  • double0201 2013-02-23 19:31
    关注

    I don't really understand your question (which session variable doesn't work?) but

    $_SESSION['CurrentUser'] = "$user";

    should be

    $_SESSION['CurrentUser'] = $user;

    评论

报告相同问题?

悬赏问题

  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题