0

我在索引会话方面遇到了一些问题。我做了一个功能来索引我想要的会话。我在报告系统上使用了它,人们不会报告同样的事情并在报告表上进行大量插入。它有效,它正在阻止人们。但是,在您第一次报告时(当 Session 未编入索引时),它会显示此错误: Notice: Undefined index: SessionReport8 in C:\xampp\htdocs\sucess\reportprocess.php on line 12

我将其设置为空。我回应它,​​它是空的,不是未定义的。如何解决?

这是功能:

    function indexarSession($Session)
{
    if (!isset($Session))
    {
        $Session = null;
        return $Session;
    }
    else
    {
        $Variavel = $Session;
        return $Variavel;
    }
}

以及它被应用的地方:

$SessionReport = $Funcoes->indexarSession($_SESSION["SessionReport" . $PostID]);

        if (!isset($SessionReport))
    {
        **DO THE INSERT*
    }
    else
    {
            **SHOW MESSAGE**
    }

先谢谢了。

4

1 回答 1

0

您在 indexarSession() 函数中使用 Session 而不检查它是否已设置。

尝试,

if(isset($_SESSION["SessionReport" . $PostID])){
   $SessionReport = $Funcoes->indexarSession($_SESSION["SessionReport" . $PostID]);
} else {
   // Session not set.
}
于 2013-03-29T22:48:19.287 回答