php - Checking for a specific user -
i have following code makes sure user logged in. want change code check specific user id. can me this?
function protect_page() { if (logged_in() === false) { header('location: protected.php'); exit(); } }
you can modify function logged_in
, pass specific user id function:
function logged_in($id) { //this function checks if user logged in , has specific id return (isset($_session['user_id']) && $_session['user_id'] === $id) ? true : false; }
you have change protect_page
function fit new logged_in
function:
function protect_page() { if (logged_in(7) === false){ header('location: protected.php'); exit(); } }