-1

尝试基于会话变量运行循环。在第一页加载没有会话。当它设置会话时,我设置会话变量和警报。

问题是,它会提醒每个页面加载:(

`
<!-- language: lang-php -->

$check = $_SESSION['cache'];  

if ($check == "xYx") {  

echo $word;  
} else {  

session_start();  
?><script>alert ("Im reading it again !")</script><?  

echo $word;  
$_SESSION['cache'] = "xYx";  
}  

`

4

2 回答 2

1
$check = $_SESSION['cache'];

发生在之前

session_start();

这是行不通的。

于 2012-05-05T00:51:09.103 回答
1

只需这样做:

session_start();
$check = $_SESSION['cache'];  

if ($check == "xYx") {  

echo $word;  
} else {  

?><script>alert ("Im reading it again !")</script><?  

echo $word;  
$_SESSION['cache'] = "xYx";  
}

正如评论所说,这只是简单地session_start()开始。

于 2012-05-05T00:52:47.247 回答