File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Session timeout in general web applications vs social apps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session timeout in general web applications vs social apps" Watch "Session timeout in general web applications vs social apps" New topic

Session timeout in general web applications vs social apps

shivang sarawagi
Ranch Hand

Joined: Jun 19, 2008
Posts: 153
Generally sessions in web applications expire after a stipulated max inactive interval. To my knowledge primarily the reason is if the session objects are not invalidated they keep exhausting the memory. So my question is

A. Is there any other reason other why web applications timeout the user session after an inactive interval?

B. Social sites never timeout the user session even if you just leave them for the entire day. How do they manage sessions? Don't the active sessions exhaust memory on their servers or JVM to be specific?

Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1341

For point A , security can be another reason for invalidating session.
For point B, we do have option in Java to configure ever running session. About whether they exhaust memory of JVM depends upon what values do we store in Session.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

If your session fills up and never empties it's a sign that you are not managing it properly. Just leaving stale data in the session, and counting upon its timeout to clear it out is a poor approach.

[Asking smart questions] [About Bear] [Books by Bear]
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Also, don't assume that a user's session data has to be stored in memory. There are other strategies.
shivang sarawagi
Ranch Hand

Joined: Jun 19, 2008
Posts: 153
Thanks for the reply guys. Can you please add any resource link or would want to elaborate on session saving strategies?.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Files or - more likely - a database are other options.
Joe Areeda
Ranch Hand

Joined: Apr 15, 2011
Posts: 331

Also a session may timeout but not require any user interaction to create another one.

For example the "stay logged in" checkboxes usually store a cookie in the client browser and that can be used to log in the next session.


It's not what your program can do, it's what your users do with the program.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

I'm not exactly sure what the question is here, but it's entirely within the rights of a web application server to periodically scan its session collection and discard sessions which have exceeded the timeout limit. In other words, don't expect that you have to explicitly dispose of sessions.

The Tomcat webapp server will store serialized sessions in a work directory. This can cause a session to be have continuity over a shutdown/restart of the webapp server. I haven't checked, but I'm sure there are options that control this. Plus, of course, Tomcat supports alternative session storage to help facilitate clustering between discrete JVMs.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Session timeout in general web applications vs social apps
It's not a secret anymore!