if (isset($_SESSION['invite_error'])) { echo $_SESSION['invite_error']; unset($_SESSION['invite_error']); }
但是,如果我离开此页面并返回到该页面,则仍会显示错误消息.如果我离开并再次回来,它将会完成.当我刷新那个页面时它是一样的… 1刷新不会摆脱它,但2会.我不能破坏整个会话,我只是想取消设置这个变量. PHP版本是5.2.5 build 6,注册全局变量是关闭的,我在这个页面的顶部调用了session_start(),我也尝试过使用no-cache标头.
<?PHP ob_start(); session_start(); $user_id = $_SESSION['user_id']; $user_name = $_SESSION['user_name']; if ($user_id==null) header("Location: /login.PHP"); if (isset($_SESSION['invite_errors'])) { $error = $_SESSION['invite_errors']; unset($_SESSION['invite_errors']); } require_once("ui/header.PHP"); ?> <div id="invite" class="content"> <?PHP if($error) { ?> <div class="errors round"> <?PHP echo $error ?> </div> <?PHP } ?> <h3>Invite Your Friends</h3> <div class="invite-form"> <form method="post" action="controllers/invite.PHP"> <div class="row"> <textarea class="txt-area" name="emails" id="emails" rows="5"></textarea> <div class="tip">Separate multiple email addresses with,</div> </div> <div class="row-submit"> <input type="submit" name="submit" id="submit" class="submit-btn" value="Submit" /> </div> </form> </div> </div> <?PHP require_once("ui/footer.PHP"); ?>