##### General Information

- Overview
- Features
- Specification
- Getting Started
- Howto Build Turbine
- Changes

##### Documentation

- Services
  - Assembler Broker Service
  - Avalon Component Service
  - Crypto Service
  - Cache Service
  - Component Service
  - Factory Service
  - Intake Service
  - JSON-RPC Service
  - JSP Service
  - Localization Service
  - MimeType Service
  - Naming Service
  - Parser Service
  - Pool Service
  - Pull Service
  - RunData Service
  - Scheduler Service
  - Security Service
  - Servlet Service
  - Session Service
  - Template Service
  - Torque Security Service
  - Torque Security Service Schema
  - UI Service
  - Unique ID Service
  - Upload Service
  - Velocity Service
  - XML-RPC Service
  - XSLT Service
- Howtos
- Wiki
- JavaDocs

##### Development

- Proposals
- How To Help
- Todo

##### Project Documentation

- Project Information
- Project Reports

##### Apache

- Apache Website
- License
- How the ASF works
- Sponsorship
- Thanks
- Security

## Overview

The Session Service was created to allow Turbine based applications to access information about the current sessions in the application's context. Some of the most obvious uses would include

- Count of the active sessions
- Determine if a given user is already logged in on another session
- Terminate a session

The service is implemented by using a listener configured in your application's deployment descriptor. The listener class is used by the container to notify the service when sessions are created or destroyed.

## Configuration

You will need to modify a few files in order to activate the service. The first modification will be in your TurbineResources.properties. See the example below for two settings that need to be present in order for the service to work.

    # -------------------------------------------------------------------
    #
    #  S E R V I C E S
    #
    # -------------------------------------------------------------------
    # Classes for Turbine Services should be defined here.
    # Format: services.[name].classname=[implementing class]
    #
    # To specify properties of a service use the following syntax:
    # service.[name].[property]=[value]

    services.SessionService.classname=org.apache.turbine.services.session.TurbineSessionService
    .
    .
    .
    # -------------------------------------------------------------------
    #
    #  S E S S I O N  S E R V I C E
    #
    # -------------------------------------------------------------------

    services.SessionService.earlyInit=true

The next modification will be your application's deployment descriptor (web.xml). Here we will configure the listener class.

    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>

        <listener>
            <listener-class>org.apache.turbine.services.session.SessionListener</listener-class>
        </listener>

        <servlet>
            <servlet-name>MyServletName</servlet-name>
            <servlet-class>org.apache.turbine.Turbine</servlet-class>
            <init-param>
                <param-name>properties</param-name>
                <param-value>/WEB-INF/conf/TurbineResources.properties</param-value>
            </init-param>
        </servlet>

    </web-app>

There is also a pull tool avilable for accessing this service. To make it available for use in your velocity templates, add the following line to your TR.props file.

    tool.session.sessionmgt = org.apache.turbine.services.session.SessionTool

## Usage

The Session Service should be accessed through the `org.apache.turbine.services.session.TurbineSession` class or the pull tool. See the javadocs for both classes for more usage information.