Zend_Application-AvailableResources-Session.xml 3.8 KB

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