Showing the user that he has logged out


I want this: If the user logs out(session destroy) then index should say: You are logged out.

if (isset($_SESSION['user']) && $_SESSION['user'] == true) {  echo "Welcome on the users page! " . $_SESSION['username'] . "!";   }    elseif (!isset($_SESSION['user'])) {   echo "You logged out..";}  

The problem I am having is that it also shows you logged out when you haven't even logged in to be able to log out. I only want it to show if the user logs out.

Also I only want "You are logged out" to show up once. If you refresh the page it should be gone