Session management in the gwt

前端 未结 3 2036
无人共我
无人共我 2021-01-28 23:39

I am working on an GWT-ext application. In this application I managed client side session. For this I write below code:

To manage the session: import com.google.gwt.user

相关标签:
3条回答
  • 2021-01-29 00:28

    I think the thing you are searchin for is:

    Window.Location.reload();

    Fire it every few secons with a timer, so the user always apper to be active.

    (Btw I have that from Window close issues in gwt -ext )

    0 讨论(0)
  • 2021-01-29 00:30

    Install a JavaScript event handler on an invisible div that covers the whole area. If it gets an event, send an AJAX request to the server.

    The server can then do whatever it needs to do. On the client side, you can wait for a reply from the AJAX request and display "You have been logged out".

    There is one drawback of this approach: Objects stored in the session will be kept alive for too long. So even if the user never logs out and just walks away (or his browser crashes), the session will stay alive.

    After a couple of days, so many dead sessions will accumulate that your server will crash.

    So the better solution is to auto logout the user as you do already and install an AJAX event handler as described above to display a message when the user returns to the browser.

    This way, your server can clean up dead sessions and the user gets a message when he can read it (when he is in front of the screen).

    Note that you can't differentiate between the user and the cleaning crew hitting the mouse.

    0 讨论(0)
  • 2021-01-29 00:39

    In the Timer, increment a variable for each second. And when user click on any button after 5 minutes or on 6th minute than check the counter variable and if the variable is greater than 6 than you can use Window.Location.reload(); to logout or reload().

    0 讨论(0)
提交回复
热议问题