prevent user from logging back in after logging out by hitting back button


prevent user from logging back in after logging out by hitting back button

Disabling browser back button by javascript is a bad idea. Here is an example that logs the user in and logs the user out and also checks if the user is logged in. When you click the logout page you're automatically logged out and redirected. Clicking back won't change anything you still won't be logged in.

in login.php file

session_start();
// If they are  logged in, send them to homee
if(isset($_SESSION['isLoggedIn'])) {
 //   header("Location: start.php");

              echo '<script language="javascript">';
        echo 'top.location.href = "start.php";';
        echo '</script>';


}

also add this after succesful login in login.php file

if(authenticate_user($myusername,$mypassword))
{
//$_SESSION['login_user']=$myusername;
$_SESSION['isLoggedIn'] = true;
---
}

for all webpages of ur site write this in common.php

session_start();
// If they are not logged in, send them to login page
if(!isset($_SESSION['isLoggedIn'])) {
    header("Location: login.php");
}

- vinod kotiya

Comments