# Zend_Application_Resource_Session

`Zend_Application_Resource_Session` allows you to configure `Zend_Session` as well as optionally initialize a session SaveHandler.

To set a session save handler, simply pass the saveHandler (case insensitive) option key to the resource. The value of this option may be one of the following:

- String: A string indicating a class implementing `Zend_Session_SaveHandler_Interface` that should be instantiated.

- Array: An array with the keys "class" and, optionally, "options", indicating a class implementing `Zend_Session_SaveHandler_Interface` that should be instantiated and an array of options to provide to its constructor.

- `Zend_Session_SaveHandler_Interface`: an object implementing this interface.

Any other option keys passed will be passed to `Zend_Session::setOptions()` to configure `Zend_Session`.

## Sample Session resource configuration

Below is a sample INI snippet showing how to configure the session resource. It sets several `Zend_Session` options, as well as configures a `Zend_Session_SaveHandler_DbTable` instance.

    resources.session.save_path = APPLICATION_PATH "/../data/session"
    resources.session.use_only_cookies = true
    resources.session.remember_me_seconds = 864000
    resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
    resources.session.saveHandler.options.name = "session"
    resources.session.saveHandler.options.primary[] = "session_id"
    resources.session.saveHandler.options.primary[] = "save_path"
    resources.session.saveHandler.options.primary[] = "name"
    resources.session.saveHandler.options.primaryAssignment[] = "sessionId"
    resources.session.saveHandler.options.primaryAssignment[] = "sessionSavePath"
    resources.session.saveHandler.options.primaryAssignment[] = "sessionName"
    resources.session.saveHandler.options.modifiedColumn = "modified"
    resources.session.saveHandler.options.dataColumn = "session_data"
    resources.session.saveHandler.options.lifetimeColumn = "lifetime"

## Bootstrap your database first!

If you are configuring the `Zend_Session_SaveHandler_DbTable` session save handler, you must first configure your database connection for it to work. Do this by either using the Db resource -- and make sure the "resources.db" key comes prior to the "resources.session" key -- or by writing your own resource that initializes the database, and specifically sets the default `Zend_Db_Table` adapter.