Synchronisation du statut de connexion entre WordPress et Discourse, fournisseur SSO Discourse

We’re in the process of adding a WordPress front end to our Discourse forum. WordPress is client SSO to Discourse (we only log in through Discourse).

I want/need the is_user_logged_in state in WordPress to be able to toggle some features on the WordPress site for folks who are logged in (and keep private from those who are not).

All works well when an individual is logged in and logs out on each machine/browser. The problem arises when a member logs in on one machine, goes to another browser or mobile device and logs in using the same account there (actually is simply identified as logged in and everything is copacetic) and then logs out there.

The original WP instance will not see the user as logged out (state for Discourse is maintained on a user level, not session).

Keeping sessions separate would probably be the best solution but seems an architectural stretch for the Discourse API.

A hack that would work for our purposes would be to simply query the Discourse server (from WP) and logout if the user has been logged out. This could be done either on a timed basis or on a page refresh on WP (e.g. in functions.php or header.php for the theme).

Am I missing something? Has someone tried something like this and willing to share their experience?