Here is my problem:
I have a login page called login.php (without HTML). When a user correctly enters his credentials, he is redirected to a specific page; we will say test.php for this example. The only links to this page are to exit the current session and return the user to index.html.
My problem is that if the user clicks the back button, he returns to login.php and you get a blank page. If you are moving away from this blank page, you have no way to return to test.php, so there is no way to exit this session.
My initial idea was to disable navigation using Javascript. In the end, I realized that this would not work, because if the user finds a way to exit this page without logging out, they will be stuck in this session, and login.php will be empty.
So, is there a way to end the current session if you press this button back? Or if login.php is rebooting? I am not very familiar with PHP, so a detailed explanation will be very useful for us.
Here is the code for the login page:
<?php <?php if(!isset($_SESSION['LOGGED_IN'])): ?> <style type='text/css'> #fslv2-main{ font-family:HelveticaNeue-Light, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;font-weight:300;font-size:14px;line-height:1.6; margin-left:auto; margin-right:auto; width: 300px; padding: 10px 10px 10px 10px; } fieldset { border: none; margin: 0; padding: 0;} .fslv2 .input { border: 1px solid #b9b9b9; padding: 5px; width: 225px; outline: none; font-size: 13px; } .fslv2 label { float: left; width: 72px; line-height: 28px; } h3 { font-weight: normal; } a { color: #4a6a81; text-decoration: none; } a:hover { color: #4a6a81; text-decoration: underline; } .button { border: 1px solid #233d4f; border-bottom: 1px solid #233d4f; background-color: #4a6a81; border-radius: 2px; padding: 6px 5px; color: #ffffff; text-shadow: 0 1px rgba(0, 0, 0, 0.1); margin-left:auto; margin-right:auto; top: 5px; width: 100px; min-width: 100px; cursor: pointer; font-size: 13px; box-shadow: rgba(0,0,0,0.2); -webkit-box-shadow: rgba(0,0,0,0.2); -moz-box-shadow: rgba(0,0,0,0.2); } .input:focus { -moz-box-shadow: inset 0 0 3px #bbb; -webkit-box-shadow: inset 0 0 3px #bbb; box-shadow: inner 0 0 3px #bbb; } .fsl p.la { text-align: center; } .success { margin: 2em auto 1em auto; border: 1px solid #337f09; padding: 5px; background-color: #dd4b39; width: 400px; text-align: center; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; font-weight: normal; font-family:HelveticaNeue-Light, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;font-weight:300;font-size:14px;line-height:1.6; } .error { margin: 2em auto 1em auto; border: 1px solid #233d4f; padding: 5px; background-color: #8bafc5; width: 400px; text-align: center; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; font-weight: normal; font-family:HelveticaNeue-Light, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;font-weight:300;font-size:14px;line-height:1.6; } </style> <div id="fslv2-main"> <?php if($secure->attempts() > 5): ?> <p>Too many failed attempts, please try again later.</p> <?php elseif(isset($_GET['forgot_password'])): ?> <fieldset class="fslv2"> <form method="post" action="#"> <p> <label for='email'>Email: </label> <input type='text' name='email' class='input'/> </p> <p><input type='submit' name='forgot_password_button' class='button' value='Send!' /></p> </form> </fieldset> <small><a href="index.html">Cancel</a></small> <?php else: ?> <fieldset class="fslv2"> <legend><?php echo $secure->site_name(); ?></legend> <form method="post" action="#"> <p> <label for='username'>Username: </label> <input type='text' name='username' class='input'/> </p> <p> <label for='password'>Password: </label> <input type='password' name='password' class='input'/> </p> <p><input type='submit' name='login' class='button' value='Login' /></p> </form> </fieldset> <?php endif; ?> </div> <?php exit(); endif; ?>