Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google APP Engine中的PHP会话存在问题_Php_Google App Engine_Session_App.yaml - Fatal编程技术网

Google APP Engine中的PHP会话存在问题

Google APP Engine中的PHP会话存在问题,php,google-app-engine,session,app.yaml,Php,Google App Engine,Session,App.yaml,我有三个文件 第一个是index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" con

我有三个文件

第一个是
index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cyber Boy Test App</title>
</head>
<body>
Hello 
<br/> This is Login System Test 
<br/>
<form method="post"  action="logincheck.php">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" name="submit" />
</form> 
</body>
</html>
<?php
session_start();
$finaluser=$_POST['username'];
if($_SESSION['auth']=="yes")
{
    header('Location: name.php');   
}
else
{
    $connection=mysql_connect('localhost','root','')or die("Could not Connect to Database ");
    $db=mysql_select_db('test', $connection) or die(" Check the Database wrong database entered ");
    $sql="SELECT name from users WHERE username='$finaluser'";
    $result=mysql_query($sql) or die("Coudl not Execute the Query");
    $num=mysql_num_rows($result);
    $result=mysql_query($sql) or die("Coudl not Execute the Query2");
    $row=mysql_fetch_array($result);
    if($num==1)
    {
        echo "Login SuccesFull";
        $_SESSION['auth']="yes";
        $_SESSION['name']=$row['name'];
        echo '<a href="name.php">To Check the Name of the User Click Here';
    }
    else
    {
        echo "Login Failed";
    }
}
?>
<?php
echo $_SESSION['name'];
?>
第三个文件是
name.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cyber Boy Test App</title>
</head>
<body>
Hello 
<br/> This is Login System Test 
<br/>
<form method="post"  action="logincheck.php">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" name="submit" />
</form> 
</body>
</html>
<?php
session_start();
$finaluser=$_POST['username'];
if($_SESSION['auth']=="yes")
{
    header('Location: name.php');   
}
else
{
    $connection=mysql_connect('localhost','root','')or die("Could not Connect to Database ");
    $db=mysql_select_db('test', $connection) or die(" Check the Database wrong database entered ");
    $sql="SELECT name from users WHERE username='$finaluser'";
    $result=mysql_query($sql) or die("Coudl not Execute the Query");
    $num=mysql_num_rows($result);
    $result=mysql_query($sql) or die("Coudl not Execute the Query2");
    $row=mysql_fetch_array($result);
    if($num==1)
    {
        echo "Login SuccesFull";
        $_SESSION['auth']="yes";
        $_SESSION['name']=$row['name'];
        echo '<a href="name.php">To Check the Name of the User Click Here';
    }
    else
    {
        echo "Login Failed";
    }
}
?>
<?php
echo $_SESSION['name'];
?>

您需要在所有使用会话变量的PHP页面(例如,在顶部)上调用session_start()


尽管它的名称session_start()不仅仅是启动会话,它还可以恢复任何已经存在的会话(请参见)。

我知道它,但它并没有在我的脑海中出现。我一直在想这和谷歌应用引擎有关。。。