Is that the entirety of the page? If so, you need to add the session_start() function to the top of the file in order to access the session.

Also, it would help to see the login script as well.