Hi There -

Have an interesting problem. Would like to be able to log someone out when they leave a particular page.

We have a flash demo that only works when someone's logged in. Someone else on our team has figured out how to log someone in when they go to that page. Now we need to figure out how to make that person logged out when they leave.

One suggestion was to use hook_menu(!may_cache) to see if someone's uid is the demo user, and if it is, then log them out. From what I understand, this is called on every page load and could be done in about three lines. Still, it's a hit with every page load, and I'm wondering if there's a more elegant solution that could be localized to the single page that they're leaving that would log them out or kill their session.

Any ideas?

Comments

nevets’s picture

You could write a small module that implements hook_exit(), something like this

YOURMODULE_exit($destination = NULL) {
  global $user;
  if ( $user->uid == UID_OF_DEMO_USER ) {
    user_logout();
  }
}