Zend_Application-AvailableResources-Session.xml 3.8 KB

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