I do not think this is rare. One possible dissolution may be to set a minimum session timeout. For example, 5 minutes. In addition, you can write a filter to increase the session timeout if the session already exists for the user. Thus, an ordinary user will have a session timeout of 30 minutes, and users on only one side will have a timeout of 5 minutes.
Here is a filter that doses the trick:
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpSession session = httpRequest.getSession(false);
if (session == null) {
chain.doFilter(request, response);
return;
}
session.setMaxInactiveInterval(30 * 60);
chain.doFilter(request, response);
}
Another good tip is to filter out crawlers like the Google bot. "Bot Detection" is a good search keyword.
source
share