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();     } }  

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -