会话在客户端服务器上的行为不同于我的

时间:2019-06-13 19:11:57

标签: php session

如果这没有最好的解释,我深表歉意,但是我对PHP不太熟悉。基本上,我有使用会话变量的代码,该变量可以在服务器上正常工作。但是,当我将代码上传到客户端服务器时,它不起作用。

这是第1页上的代码:

        <form method="post" action="minecraft.php" autocomplete="off">

        <div id="order-avatar-image" class="avatar" style="background-image: 
        url('https://minotar.net/avatar/steve');"></div>

        <input type="text" value="" id="form-username" name="form-username" 
        placeholder="Enter minecraft username...">

        <input type="submit" value="" class="submithome" name="Submit" 
        id="Submit">
        </form>

第二页会将第1页的表单数据存储到会话中。

<?php
session_start();
$formuser = $_POST['form-username'];
$_SESSION['form-user'] = $formuser;
?>

它在第二页上很好地呼应了它

<?php
    if(isset($_SESSION['form-user'])){
?>

<div id="order-avatar-image" style="background-image: url('https://minotar.net/avatar/<?php echo $formuser; ?>');margin:0 auto;margin-bottom:18px;width:40px !important;height:40px !important;background-size:40px 40px;" ></div>

    <? echo "Hi "; ?>
    <span> 
        <?
            echo $formuser;
        ?></span>. Choose your plan
        <?
        }
            else {
                echo"Powerful, Secure, & Affordable";
            }
        ?>

在第三页上,我有session_start();在页面顶部(不确定是否需要其他内容吗?),但是会话中断并且变量没有正确显示。

在此处可以正常使用的服务器上:https://varcoe.net/clients/ggservers/code-您可以使用“启动服务器”下的表单对其进行测试,它将转到第二页并显示输入的用户名并更新头像。然后在第三页上的输入框中显示用户名/头像。

该服务器上的PHPInfo:https://varcoe.net/clients/ggservers/code/phpinfo.php(不确定这是因为我使用的是lightspeed,还是他使用的是Apache,但认为没有区别)。

无法使用的服务器:https://stage36.ggservers.com/(它可以工作到第3页,用户名/头像应该在输入框中,而不是。在第2页上可以正常使用。) 和phpinfo:https://stage36.ggservers.com/phpinfo.php

任何帮助将不胜感激。

0 个答案:

没有答案