php会话提前到期

时间:2016-07-21 07:24:19

标签: php session

Php会话在记录后到期。当我将项目放在服务器中时,会发生这种情况,但是当我在localhost中工作时,不会发生此问题。

也就是说,在我使用用户名和密码登录页面后,当我点击任何菜单时,我无法点击任何菜单,它会回滚到登录页面。这个问题在服务器中发生,只有它在localhost中才能完美运行。

function test_input($data)
{
    trim($data);
    stripslashes($data);
    htmlspecialchars($data);
    mysql_real_escape_string($data);
    return $data;
}






if(empty($_POST['txtname']))
{
     $usererr="Valid username required!";
}
else if(!preg_match('/^[A-Za-z0-9_-]*$/',$_POST['txtname']))
{
     $usererr="Invalid charactors found!";
}
else if(strlen($_POST['txtname'])>=10)
{
    $usererr="Overlimit of username charactors!";
}
else
{
    test_input($_POST['txtname']);
}


if(empty($_POST['txtpass']))
{
    $passerr="Valid Password required!";
}
else if(!preg_match('/^[A-Za-z0-9_-]*$/',$_POST['txtpass']))
{
    $passerr="Invalid charactors found!";
}
else if(strlen($_POST['txtpass'])>=10)
{
    echo "Overlimit of password charactors!";
}
else
{
        test_input($_POST['txtpass']);
}



    $uname=@mysql_real_escape_string($_POST['txtname']);
    $pass=@mysql_real_escape_string($_POST['txtpass']);


    $uname1=md5($uname);

    $pass1=md5($pass);

    //echo"$uname1"."<br/>"."$pass1";


    $rs=@mysql_query("select * from salve_admin where Name='".$uname1."' and Pass='".$pass1."' ");

    if(@mysql_num_rows($rs)==1)
    {

        $rs1=@mysql_fetch_object($rs);

        $_SESSION['user']=$rs1->Name;


    }


}

0 个答案:

没有答案
相关问题