Login Check Function For Authentication Use On Every File For Auth.

this function is intended to be used as a part of an authentication system to check if a user is logged in as an admin. If the admin session is not set or is empty, it redirects the user to the index.php page.

28

Arun Kr.
09-Jun-24

designed to check if a user is logged in as an admin. If the $_SESSION['ADMIN_ID'] is empty, it redirects the user to the index.php page.

However, there's a small typo in the function name. It should be admin_login_check instead of adimn_login_check. Additionally, it's good practice to include an exit() after the header('Location: ../index.php'); to ensure that no further code execution occurs after the redirection.

public function admin_login_check()
{
    if(empty($_SESSION['ADMIN_ID']))
    {
        header('Location: ../index.php');
        exit();
    }       
}
@Since 2024 Arun'Log Powered by Arun Git