PHP不会创建会话

时间:2014-12-16 08:35:38

标签: php session

经过检查,这实际上是问题:

Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current   setting of session.save_path is correct (/mnt/ramdisk) in Unknown on line 0

1 个答案:

答案 0 :(得分:-1)

在代码的开头添加session_start(),看看是否有帮助。

session_start();
$file = fopen($path, "r");
        if($file) 
        {
            if(isSet($_POST['login']))
            {
                while(($line = fgets($file)) !== false) 
                {
                    $user_data=explode(";", $line);

                    if($_POST['login']==trim($user_data[0]))
                    {
                        if(md5($_POST['pass'])==trim($user_data[1]))
                        {
                            $_SESSION['logged']=htmlspecialchars($_POST['login']);
                            header('Location:vms.php');
                            break;
                        }
                    }
                }
                echo "
                        <script>
                            alert('Invalid login or password');
                        </script>
                    ";
            }
        }