1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect2 id="zend.application.available-resources.session">
<title>Zend_Application_Resource_Session</title>
<para>
<classname>Zend_Application_Resource_Session</classname> allows you to configure
<classname>Zend_Session</classname> as well as optionally initialize a session
SaveHandler.
</para>
<para>
To set a session save handler, simply pass the <property>saveHandler</property>
(case insensitive) option key to the resource. The value of this option
may be one of the following:
</para>
<itemizedlist>
<listitem>
<para>
<type>String</type>: A string indicating a class implementing
<classname>Zend_Session_SaveHandler_Interface</classname> that should be
instantiated.
</para>
</listitem>
<listitem>
<para>
<type>Array</type>: An array with the keys "class" and, optionally,
"options", indicating a class implementing
<classname>Zend_Session_SaveHandler_Interface</classname> that should be
instantiated and an array of options to provide to its constructor.
</para>
</listitem>
<listitem>
<para>
<classname>Zend_Session_SaveHandler_Interface</classname>: an object
implementing this interface.
</para>
</listitem>
</itemizedlist>
<para>
Any other option keys passed will be passed to
<methodname>Zend_Session::setOptions()</methodname> to configure
<classname>Zend_Session</classname>.
</para>
<example id="zend.application.available-resources.session.configExample">
<title>Sample Session resource configuration</title>
<para>
Below is a sample <acronym>INI</acronym> snippet showing how to configure the session
resource. It sets several <classname>Zend_Session</classname> options, as well
as configures a <classname>Zend_Session_SaveHandler_DbTable</classname> instance.
</para>
<programlisting language="ini"><![CDATA[
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"
]]></programlisting>
</example>
<note>
<title>Bootstrap your database first!</title>
<para>
If you are configuring the
<classname>Zend_Session_SaveHandler_DbTable</classname> session save
handler, you must first configure your database connection for it to
work. Do this by either using the <link
linkend="zend.application.available-resources.db">Db</link>
resource -- and make sure the "<property>resources.db</property>" key comes prior to
the "<property>resources.session</property>" key -- or by writing your own resource
that initializes the database, and specifically sets the default
<classname>Zend_Db_Table</classname> adapter.
</para>
</note>
</sect2>
|