How to check if a user is logged in? in WordPress

I am new to WordPress. In my theme in header.php, I want to set up different navigation bars for logged-in and guest users.

I want to add a condition in my header.php file to check if the user has logged in and then display one nav else display the other nav.

Any advice would be helpful.

The function you are looking for is is_user_logged_in()

You can write the condition like this.

if ( is_user_logged_in() ) {
   // your code for logged in user 
} else {
   // your code for logged out user 

For setting up the menu for the logged-in user or guest user you can use the code below.

wp_nav_menu( array(
    'theme_location' => is_user_logged_in() ? 'logged-in-menu' : 'logged-out-menu'
) );

If you need more help you can check this page.