views:

91

answers:

1

We are working on a mission critical web application, we would like to expire the application's session out when a user presses the browser back button.

Please help me with my problem.

Thanks in advance.

A: 

The problem I see is that if someone uses the back button to correct a mistake, they're not going to be happy to have to log back in to re-enter/re-do whatever they thought they'd already done.

If you're okay with that -huge- usability problem, UI inconsistency and breaking the users' learned behaviour...

    $this_page = $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
    $history[] = $this_page;

/* assuming you're continually passing the $history variable
to subsequent pages via post, get, Ajax... */

    if (in_array($this_page, $history)) {

      // end session

    }

    else {

      // continue/maintain session

    }

If you need the session to be ended by pressing a particular button -rather than simply comparing the current page with a page in the browser-history- I'd suggest using JS/jQuery. I believe that the backspace button is key 8, but I'm still terrible at JS, so I can't offer any real help there.

David Thomas
thanks for your reply and i will try out and reply you back
Jerry Pine