Include file with a condition

I’d like to include a file (ex: footer.php) when a user is logged in (in my case userIdentity.data.userid is present), and not show it if not logged in.
How can I achieve this pls?

Community Page
Last updated: