In WordPress many a times you might need to check whether a user is logged in or not. This can be easily done, check the code below
if ( is_user_logged_in() )
echo ‘Hello, user, you are logged in!’;
echo ‘Halo !, Stranger ‘;
The is_user_logged_in() is a built in WordPress function which return a boolean value. A value of true is returned is the user is logged in or false is returned otherwise.