Php 使用主页上的会话变量显示帐户链接

Php 使用主页上的会话变量显示帐户链接,php,mysql,session-variables,Php,Mysql,Session Variables,我需要一些链接(与用户帐户相关)出现在登录用户的索引页上。我有一个会话变量“email”。 我这么做了,但没用 <div id="left"> left div content </div> <div id=-"right"> <?php if(isset($_SESSION['email'])) { ?> //show user some links to his accou

我需要一些链接(与用户帐户相关)出现在登录用户的索引页上。我有一个会话变量“email”。
我这么做了,但没用

<div id="left">
    left div content
    </div>

    <div id=-"right">

    <?php

    if(isset($_SESSION['email']))
    {

    ?>
    //show user some links to his account.
    <?php
    }
    else
    {
    ?>
    //show login and register forms
    <?php
    }
    ?>
    </div>

左div内容
//向用户显示其帐户的一些链接。
//显示登录和注册表单


到php手册。

您在

<?php 

   session_start();

  //followed by rest of the code.

?>

应该是

session_start()


然后是进一步的代码。

您是否添加了session_start();在页面顶部?您是否调用了
session_start()在脚本顶部?您的问题非常不清楚。你能描述一下你想取得更好的成绩吗?另外,
id=-
不是DomeElement的正确id。是否需要添加会话_start();到我使用会话变量的每个页面?(刚开始学习php。)是的,这是必要的:)我正在使用localhost。每当我在登录后的新选项卡中打开index.php时,它都会显示登录和注册表单。但在同样的情况下,它是有效的。怎么说?你能再解释一下吗?
<?php 

   session_start();

  //followed by rest of the code.

?>