ShaolinF Posted October 16, 2007 Share Posted October 16, 2007 Hey Guys, A user submits a form and thus a session has been created. What I want to do is if the user presses the back button or decides to re-submit another form, it'll overwrite the current one. How can I do this ? Link to comment https://forums.phpfreaks.com/topic/73390-deleting-sessions-if-user-restarts/ Share on other sites More sharing options...
pocobueno1388 Posted October 16, 2007 Share Posted October 16, 2007 Just simply give the session a new value. $_SESSION['var'] = 'new val'; Link to comment https://forums.phpfreaks.com/topic/73390-deleting-sessions-if-user-restarts/#findComment-370269 Share on other sites More sharing options...
ShaolinF Posted October 16, 2007 Author Share Posted October 16, 2007 Well I tried that, but it seems like it doesn't work. When I submit a form I get blank entries on the process.php page. Also, I want the user to beable to refresh the page and not lose the data. Here is my code: <?php ob_start(); session_start(); If (!isset($_POST['validate'])) { header ("location: index.htm"); } if (!isset($_SESSION['LOGGEDIN'])) // If user is not logged in { //Add session echo "session was not set! User was not logged in" . "<BR>"; $_SESSION['LOGGEDIN'] = TRUE; $_SESSION['NAME'] = $_POST['name']; $_SESSION['CONTACTNO'] = $_POST['contact']; $_SESSION['EMAILADD'] = $_POST['email']; $_SESSION['GENDER'] = $_POST['sex']; } else { echo "<BR>" . "session is set! User is logged in"; } ?> Link to comment https://forums.phpfreaks.com/topic/73390-deleting-sessions-if-user-restarts/#findComment-370275 Share on other sites More sharing options...
kratsg Posted October 16, 2007 Share Posted October 16, 2007 Use the referrer function. <?php $refer=$_SERVER['HTTP_REFERER']; if($refer == [b]page to click back from[/b]){ //overwrite session } else { //do nothing } ?> Link to comment https://forums.phpfreaks.com/topic/73390-deleting-sessions-if-user-restarts/#findComment-370284 Share on other sites More sharing options...
ShaolinF Posted October 16, 2007 Author Share Posted October 16, 2007 Ok, I doing the following and it still doesn't work: $refer=$_SERVER['HTTP_REFERER']; if($refer == ("http://www.mysite.com/test/")){ echo "overwrite session"; $_SESSION['LOGGEDIN'] = FALSE; } else { //do nothing } Link to comment https://forums.phpfreaks.com/topic/73390-deleting-sessions-if-user-restarts/#findComment-370290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.