Just put 'session_start()' at the top of all you pages.
When a person first visits your pages, you initialize the session with
'loggedin=0'
That means the user has visited your site, but did not log on.
Then you present a login box, and when the user enters his username/password, you change the 'loggedin' from 0 to 1.
When the user logs out again, you set the 'loggedin' to zero.