Sokrates Documentation - Sessions

Sessions
You can request a session context by calling the .getSession() method of the current request. A session holds your data between requests. The identification of this session is done by a session ID.

There are 2 possibilities to store this ID:
  • in a cookie
  • in the URL
Which method to use is defined by the sessionid parameter in the servlet container configuration. Valid values are cookie and url.

If you select sessionid=url you must use HttpServletResponse#encodeURL(String) on every URL your servlet produces because the session ID must be crypted into the URL instead of storing the ID into a cookie. A typical URL with a session ID in the URL looks like this:

http://www.harddiskcafe.de/taskplaner?hAction=login&ssrsessionid=IDee82a59375-3

Session manager
The session manager handles storing, retrieving and deleting of outdated sessions. The session manager is pluggable so you can replace it with your own version and implement your own session management rules. The parameter sessionmanagerconfig can point to an init file (.ini) with a valid configuration; if the parameter is left empty the "Memory Session Manager" mode is used with its default values.

We deliver two different, preconfigured versions in the Sokrates distribution:
  1. Memory Session Manager (Init file: mem_sessionmgr.ini)
    Stores everything in the computers memory. You can define:
    • the time interval after which time a session is invalidated
    • the time after which the session manager should remove invalid sessions from memory.
    See the example in the .ini file.
  2. File Session Manager (Init file: file_sessionmngr.ini)
    Keeps only a small index in the memory and writes the sessiondata to disk (using serialization). In addition to the Memory Session Manager you can define:
    • the storage directory (should be a fast hard drive)
    • the maximum number of files to remove per cleanup. We limit the number to be deleted per cleanup because during the deletion of outdated files no other process can create, read or invalidate any session. If your session directory fills up with files you should lower the value in sessioncleanupcycle which will cause the file cleanup to run more frequently.
 << How does it work ? <<     >> to be continued >>
Main - Installation - Stopping and Restarting - Adding New Servlets - Better Structures - How does it work ?Sessions -