isset( $\_SESSION[ 'user' ] ). Checking if $\_SESSION[ 'user' ][ 'username' ] is set is wrong, because it tries to access the user key. Enable warnings in your PHP configuration and test these things.