My site has a form used to invite friends. This is a simple text box and a submit button. If there is an error, I redirect back to this page and post an error message if they have a set of sessions.
if (isset($_SESSION['invite_error'])) { echo $_SESSION['invite_error']; unset($_SESSION['invite_error']); }
However, if I go back to this page and return to it, the error message is still displayed. If I leave and return again, it will be done. The same thing when I update this page ... 1 update will not get rid of it, but 2 will. I canβt destroy the whole session, I just want to disable this variable. The PHP version is 5.2.5 build 6, the registration of global variables is disabled, I call session_start () at the top of this page, I also tried to use the header without a cache.
Edit: Added full code.
<?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"); ?>
php session session-variables
Seth
source share