Developing a Website is Not Child's Play

jerryjohnson 11 Décembre 2018

  1. jerryjohnson

    jerryjohnson Membre

    This is done with the Clone My Sites Review PHP header() function.
    Line 1: Line 2: if ($_SESSION['user_credential'] 'admin') {
    Line 3: header("location: login.php");
    Line 4: }
    Line 5:?>
    In line 2 above, the session information is checked to see if a session array key 'user_credential' exists, and is not already equal to 'admin'. If the session key doesn't equal admin, the header function is called and the page is redirected to the login.php page. This ensures that the user won't be able to see critical information with permission.
    Note: The session key is set when the user logs in correctly after submitting the login form. It will be empty if they have not logged in yet.
    PHP headers are a very quick and efficient way to change the flow of a program. They are typically called when a users doesn't have the correct credentials or privileges.

Partager cette page