Check user session by HeartBeat
-
Hello, I use script which when user is signing in it deletes other sessions with this account (only one person can be logged in on one account). And it works good, e.g. if im logged in on mobile and then i logged in on PC, my session on mobile is destroyed.
But, I’ve to improve it. I’ve to add script which will check user session in some interval (HeartBeat API??). Thats cause i’ve some pages with paid access and even if user session is destroyed, user can stay on this page and he will be logged out on next interaction with website but I’ve to redirect out him from page with paid access if his session was destroyed.Now I’ve sth like this:
function heartbeat_init() { wp_enqueue_script('heartbeat'); add_action("wp_footer", "heartbeat_footer"); } add_action("init", "heartbeat_init"); function heartbeat_footer() { ?> <script> jQuery(document).ready(function() { jQuery(document).trigger('heartbeat-tick.wp-auth-check', [ {'wp-auth-check': false} ]) }); </script> <?php }
But it does nothing. Whats wrong?
Summary: how can i check user session in some interval?
- The topic ‘Check user session by HeartBeat’ is closed to new replies.