dsm13698679318 2013-11-28 05:44
浏览 55

php会话立即被破坏

It seems that sessions work when I set them for an instant, and then they are destroyed. Here is my phpinfo page, can anyone see the problem? I don't have access to the phpini file. Can you check my cookie settings and tell me if I can use those instead? http://cksgrill.net/phpinfo.php

[code]

<!DOCTYPE html>
<script src="/javascript/header.js"></script>
<?

session_set_cookie_params(3000); 
session_start();
ob_start();
ini_set('session.gc_maxlifetime', 6 * 60 * 60);
$session_expiration = time() + 3600 * 24 * 2;
if((($_POST['name'])and($_POST['password']))or(($_POST['name']!="")and($_POST['password']!="")))
{
    $_SESSION['name']=$_POST['name'];
    $_SESSION['password']=$_POST['password'];
    echo $_SESSION['name'];
    echo $_POST['name'];
    echo $_SESSION['password'];
    echo $_POST['password'];
}


// redifine variables for different server
require_once "mysqlconfig.php";  
require_once "textprep.php";  

// connect to database
global $connection;
$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS); 
if (!$connection)
{
    die("Database connection failed: " . mysql_error());
}

// select database
$db_select = mysql_select_db(DB_NAME,$connection);
if (!$db_select)
{
    die("Database selection failed: " . mysql_error());
}

//check if logged in
$result = mysql_query("SELECT * FROM admin");
if (!$result)
{
    die("Database query failed: " . mysql_error());
}

// get table names as mysql feedback
$i=0;
while ($row = mysql_fetch_array($result)) 
{
    $name[$i]=$row['name'];
    $password[$i]=$row['password'];
    $rank[$i]=$row['rank'];

    //echo "\$name[$i]=".$row['name'];
    //echo "\$password[$i]=".$row['password'];
    //echo "\$rank[$i]=".$row['rank'];

    $i++;
}

//check if logged in
$log=false;
for($j=0;$j<$i;$j++)
{
    //echo "<p>(".$name[$j]."==".$_SESSION['name'].")and(".$password[$j]."==".$_SESSION['password'].")</p>";
    if(($name[$j]==$_SESSION['name'])and($password[$j]==$_SESSION['password']))
    {
        $log=true;
        echo logged." ".$log;
    }
}
if($log==true)
{
[/code]
  • 写回答

2条回答 默认 最新

  • dougu5886 2013-11-28 05:54
    关注

    Just add this code below session_start();

    <?php session_start();
    ob_start();
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)