How can I check in my website if the user is logged in to my Discourse?

i think you may need to get the user ID from the SSO payload and then use a Discourse API request get the username and current login status.