Zend_Session-GlobalSessionManagement.xml 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.session.global_session_management">
  4. <title>Global Session Management</title>
  5. <para>
  6. The default behavior of sessions can be modified using the static methods of <classname>Zend_Session</classname>. All management and
  7. manipulation of global session management occurs using <classname>Zend_Session</classname>, including configuration of the
  8. <ulink url="http://www.php.net/session#session.configuration">usual options provided by ext/session</ulink>,
  9. using <methodname>Zend_Session::setOptions()</methodname>. For example, failure to insure the use of a safe
  10. <code>save_path</code> or a unique cookie name by ext/session using <methodname>Zend_Session::setOptions()</methodname> may
  11. result in security issues.
  12. </para>
  13. <sect2 id="zend.session.global_session_management.configuration_options">
  14. <title>Configuration Options</title>
  15. <para>
  16. When the first session namespace is requested, <classname>Zend_Session</classname> will automatically start the <acronym>PHP</acronym> session, unless
  17. already started with
  18. <link linkend="zend.session.advanced_usage.starting_a_session"><methodname>Zend_Session::start()</methodname></link>.
  19. The underlying <acronym>PHP</acronym> session will use defaults from <classname>Zend_Session</classname>, unless modified first by
  20. <methodname>Zend_Session::setOptions()</methodname>.
  21. </para>
  22. <para>
  23. To set a session configuration option, include the basename (the part of the name after
  24. "<code>session.</code>") as a key of an array passed to <methodname>Zend_Session::setOptions()</methodname>. The
  25. corresponding value in the array is used to set the session option value. If no options are set by the
  26. developer, <classname>Zend_Session</classname> will utilize recommended default options first, then the default php.ini settings.
  27. Community feedback about best practices for these options should be sent to
  28. <ulink url="mailto:fw-auth@lists.zend.com">fw-auth@lists.zend.com</ulink>.
  29. </para>
  30. <example id="zend.session.global_session_management.setoptions.example">
  31. <title>Using Zend_Config to Configure Zend_Session</title>
  32. <para>
  33. To configure this component using
  34. <link linkend="zend.config.adapters.ini"><classname>Zend_Config_Ini</classname></link>, first add the
  35. configuration options to the <acronym>INI</acronym> file:
  36. </para>
  37. <programlisting language="ini"><![CDATA[
  38. ; Accept defaults for production
  39. [production]
  40. ; bug_compat_42
  41. ; bug_compat_warn
  42. ; cache_expire
  43. ; cache_limiter
  44. ; cookie_domain
  45. ; cookie_lifetime
  46. ; cookie_path
  47. ; cookie_secure
  48. ; entropy_file
  49. ; entropy_length
  50. ; gc_divisor
  51. ; gc_maxlifetime
  52. ; gc_probability
  53. ; hash_bits_per_character
  54. ; hash_function
  55. ; name should be unique for each PHP application sharing the same
  56. ; domain name
  57. name = UNIQUE_NAME
  58. ; referer_check
  59. ; save_handler
  60. ; save_path
  61. ; serialize_handler
  62. ; use_cookies
  63. ; use_only_cookies
  64. ; use_trans_sid
  65. ; remember_me_seconds = <integer seconds>
  66. ; strict = on|off
  67. ; Development inherits configuration from production, but overrides
  68. ; several values
  69. [development : production]
  70. ; Don't forget to create this directory and make it rwx (readable and
  71. ; modifiable) by PHP.
  72. save_path = /home/myaccount/zend_sessions/myapp
  73. use_only_cookies = on
  74. ; When persisting session id cookies, request a TTL of 10 days
  75. remember_me_seconds = 864000
  76. ]]></programlisting>
  77. <para>
  78. Next, load the configuration file and pass its array representation to
  79. <methodname>Zend_Session::setOptions()</methodname>:
  80. </para>
  81. <programlisting language="php"><![CDATA[
  82. $config = new Zend_Config_Ini('myapp.ini', 'development');
  83. Zend_Session::setOptions($config->toArray());
  84. ]]></programlisting>
  85. </example>
  86. <para>
  87. Most options shown above need no explanation beyond that found in the standard <acronym>PHP</acronym> documentation, but those
  88. of particular interest are noted below.
  89. <itemizedlist mark="opencircle">
  90. <listitem>
  91. <para>
  92. boolean <code>strict</code> - disables automatic starting of <classname>Zend_Session</classname> when
  93. using <code>new Zend_Session_Namespace()</code>.
  94. </para>
  95. </listitem>
  96. <listitem>
  97. <para>
  98. integer <code>remember_me_seconds</code> - how long should session id cookie persist, after user
  99. agent has ended (e.g., browser application terminated).
  100. </para>
  101. </listitem>
  102. <listitem>
  103. <para>
  104. string <code>save_path</code> - The correct value is system dependent, and should be provided by
  105. the developer using an <emphasis>absolute path</emphasis> to a directory readable
  106. and writable by the <acronym>PHP</acronym> process. If a writable path is not supplied, then
  107. <classname>Zend_Session</classname> will throw an exception when started (i.e., when <methodname>start()</methodname>
  108. is called).
  109. </para>
  110. <note>
  111. <title>Security Risk</title>
  112. <para>
  113. If the path is readable by other applications, then session hijacking might be possible. If
  114. the path is writable by other applications, then
  115. <ulink url="http://en.wikipedia.org/wiki/Session_poisoning">session poisoning</ulink>
  116. might be possible. If this path is shared with other users or other <acronym>PHP</acronym> applications,
  117. various security issues might occur, including theft of session content, hijacking of
  118. sessions, and collision of garbage collection (e.g., another user's application might cause
  119. <acronym>PHP</acronym> to delete your application's session files).
  120. </para>
  121. <para>
  122. For example, an attacker can visit the victim's website to obtain a session cookie. Then, he
  123. edits the cookie path to his own domain on the same server, before visiting his own website
  124. to execute <methodname>var_dump($_SESSION)</methodname>. Armed with detailed knowledge of the victim's
  125. use of data in their sessions, the attacker can then modify the session state (poisoning the
  126. session), alter the cookie path back to the victim's website, and then make requests from
  127. the victim's website using the poisoned session. Even if two applications on the same server
  128. do not have read/write access to the other application's <code>save_path</code>, if the
  129. <code>save_path</code> is guessable, and the attacker has control over one of these two
  130. websites, the attacker could alter their website's <code>save_path</code> to use the other's
  131. save_path, and thus accomplish session poisoning, under some common configurations of <acronym>PHP</acronym>.
  132. Thus, the value for <code>save_path</code> should not be made public knowledge and should be
  133. altered to a secure location unique to each application.
  134. </para>
  135. </note>
  136. </listitem>
  137. <listitem>
  138. <para>
  139. string <code>name</code> - The correct value is system dependent and should be provided by the
  140. developer using a value <emphasis>unique</emphasis> to the application.
  141. </para>
  142. <note>
  143. <title>Security Risk</title>
  144. <para>
  145. If the <code>php.ini</code> setting for <code>session.name</code> is the same (e.g., the
  146. default "PHPSESSID"), and there are two or more <acronym>PHP</acronym> applications accessible through the same
  147. domain name then they will share the same session data for visitors to both websites.
  148. Additionally, possible corruption of session data may result.
  149. </para>
  150. </note>
  151. </listitem>
  152. <listitem>
  153. <para>
  154. boolean <code>use_only_cookies</code> - In order to avoid introducing additional security risks,
  155. do not alter the default value of this option.
  156. <note>
  157. <title>Security Risk</title>
  158. <para>
  159. If this setting is not enabled, an attacker can easily fix victim's session ids, using
  160. links on the attacker's website, such as
  161. <code>http://www.example.com/index.php?PHPSESSID=fixed_session_id</code>. The fixation
  162. works, if the victim does not already have a session id cookie for example.com. Once a
  163. victim is using a known session id, the attacker can then attempt to hijack the session
  164. by pretending to be the victim, and emulating the victim's user agent.
  165. </para>
  166. </note>
  167. </para>
  168. </listitem>
  169. </itemizedlist>
  170. </para>
  171. </sect2>
  172. <sect2 id="zend.session.global_session_management.headers_sent">
  173. <title>Error: Headers Already Sent</title>
  174. <para>
  175. If you see the error message, "Cannot modify header information - headers already sent", or, "You must call
  176. ... before any output has been sent to the browser; output started in ...", then carefully examine the
  177. immediate cause (function or method) associated with the message. Any actions that require sending <acronym>HTTP</acronym>
  178. headers, such as sending a cookie, must be done before sending normal output (unbuffered output), except
  179. when using <acronym>PHP</acronym>'s output buffering.
  180. </para>
  181. <itemizedlist mark="opencircle">
  182. <listitem>
  183. <para>
  184. Using <ulink url="http://php.net/outcontrol">output buffering</ulink> often is sufficient to prevent
  185. this issue, and may help improve performance. For example, in <code>php.ini</code>,
  186. "<code>output_buffering = 65535</code>" enables output buffering with a 64K buffer. Even though
  187. output buffering might be a good tactic on production servers to increase performance, relying only
  188. on buffering to resolve the "headers already sent" problem is not sufficient. The application must
  189. not exceed the buffer size, or the problem will occur whenever the output sent (prior to the <acronym>HTTP</acronym>
  190. headers) exceeds the buffer size.
  191. </para>
  192. </listitem>
  193. <listitem>
  194. <para>
  195. Alternatively, try rearranging the application logic so that actions manipulating headers are
  196. performed prior to sending any output whatsoever.
  197. </para>
  198. </listitem>
  199. <listitem>
  200. <para>
  201. If a <classname>Zend_Session</classname> method is involved in causing the error message, examine the method carefully, and
  202. make sure its use really is needed in the application. For example, the default usage of
  203. <methodname>destroy()</methodname> also sends an <acronym>HTTP</acronym> header to expire the client-side session cookie. If this
  204. is not needed, then use <methodname>destroy(false)</methodname>, since the instructions to set cookies are sent
  205. with <acronym>HTTP</acronym> headers.
  206. </para>
  207. </listitem>
  208. <listitem>
  209. <para>
  210. Alternatively, try rearranging the application logic so that all actions manipulating headers are
  211. performed prior to sending any output whatsoever.
  212. </para>
  213. </listitem>
  214. <listitem>
  215. <para>
  216. Remove any closing "<code>?&gt;</code>" tags, if they occur at the end of a <acronym>PHP</acronym> source file. They
  217. are not needed, and newlines and other nearly invisible whitespace following the closing tag can
  218. trigger output to the client.
  219. </para>
  220. </listitem>
  221. </itemizedlist>
  222. </sect2>
  223. <sect2 id="zend.session.global_session_management.session_identifiers">
  224. <title>Session Identifiers</title>
  225. <para>
  226. Introduction: Best practice in relation to using sessions with Zend Framework calls for using a browser cookie (i.e.
  227. a normal cookie stored in your web browser), instead of embedding a unique session identifier in <acronym>URL</acronym>s as
  228. a means to track individual users. By default this component uses only cookies to maintain session
  229. identifiers. The cookie's value is the unique identifier of your browser's session. <acronym>PHP</acronym>'s ext/session
  230. uses this identifier to maintain a unique one-to-one relationship between website visitors, and
  231. persistent session data storage unique to each visitor. <classname>Zend_Session</classname>* wraps this storage mechanism
  232. (<varname>$_SESSION</varname>) with an object-oriented interface. Unfortunately, if an attacker gains access
  233. to the value of the cookie (the session id), an attacker might be able to hijack a visitor's session.
  234. This problem is not unique to <acronym>PHP</acronym>, or Zend Framework. The <methodname>regenerateId()</methodname> method allows
  235. an application to change the session id (stored in the visitor's cookie) to a new, random, unpredictable
  236. value. Note: Although not the same, to make this section easier to read, we use the terms "user agent"
  237. and "web browser" interchangeably.
  238. </para>
  239. <para>
  240. Why?: If an attacker obtains a valid session identifier, an attacker might be able to impersonate a
  241. valid user (the victim), and then obtain access to confidential information or otherwise manipulate the
  242. victim's data managed by your application. Changing session ids helps protect against session hijacking.
  243. If the session id is changed, and an attacker does not know the new value, the attacker can not use the
  244. new session id in their attempts to hijack the visitor's session. Even if an attacker gains access to an
  245. old session id, <methodname>regenerateId()</methodname> also moves the session data from the old session id "handle"
  246. to the new one, so no data remains accessible via the old session id.
  247. </para>
  248. <para>
  249. When to use regenerateId(): Adding <methodname>Zend_Session::regenerateId()</methodname> to your Zend Framework
  250. bootstrap yields one of the safest and most secure ways to regenerate session id's in user agent
  251. cookies. If there is no conditional logic to determine when to regenerate the session id, then there are
  252. no flaws in that logic. Although regenerating on every request prevents several possible avenues of
  253. attack, not everyone wants the associated small performance and bandwidth cost. Thus, applications
  254. commonly try to dynamically determine situations of greater risk, and only regenerate the session ids in
  255. those situations. Whenever a website visitor's session's privileges are "escalated" (e.g. a visitor
  256. re-authenticates their identity before editing their personal "profile"), or whenever a security
  257. "sensitive" session parameter change occurs, consider using <methodname>regenerateId()</methodname> to create a new
  258. session id. If you call the <methodname>rememberMe()</methodname> function, then don't use
  259. <methodname>regenerateId()</methodname>, since the former calls the latter. If a user has successfully logged into
  260. your website, use <methodname>rememberMe()</methodname> instead of <methodname>regenerateId()</methodname>.
  261. </para>
  262. <sect3 id="zend.session.global_session_management.session_identifiers.hijacking_and_fixation">
  263. <title>Session Hijacking and Fixation</title>
  264. <para>
  265. Avoiding <ulink url="http://en.wikipedia.org/wiki/Cross_site_scripting">cross-site script (XSS)
  266. vulnerabilities</ulink> helps preventing session hijacking. According to
  267. <ulink url="http://secunia.com/">Secunia's</ulink> statistics XSS problems occur frequently, regardless
  268. of the languages used to create web applications. Rather than expecting to never have a XSS problem with
  269. an application, plan for it by following best practices to help minimize damage, if it occurs. With XSS,
  270. an attacker does not need direct access to a victim's network traffic. If the victim already has a
  271. session cookie, Javascript XSS might allow an attacker to read the cookie and steal the session. For
  272. victims with no session cookies, using XSS to inject Javascript, an attacker could create a session id
  273. cookie on the victim's browser with a known value, then set an identical cookie on the attacker's
  274. system, in order to hijack the victim's session. If the victim visited an attacker's website, then the
  275. attacker can also emulate most other identifiable characteristics of the victim's user agent. If your
  276. website has an XSS vulnerability, the attacker might be able to insert an <acronym>AJAX</acronym> Javascript that secretly
  277. "visits" the attacker's website, so that the attacker knows the victim's browser characteristics and
  278. becomes aware of a compromised session at the victim website. However, the attacker can not arbitrarily
  279. alter the server-side state of <acronym>PHP</acronym> sessions, provided the developer has correctly set the value for the
  280. <code>save_path</code> option.
  281. </para>
  282. <para>
  283. By itself, calling <methodname>Zend_Session::regenerateId()</methodname> when the user's session is first used, does
  284. not prevent session fixation attacks, unless you can distinguish between a session originated by an
  285. attacker emulating the victim. At first, this might sound contradictory to the previous statement above,
  286. until we consider an attacker who first initiates a real session on your website. The session is "first
  287. used" by the attacker, who then knows the result of the initialization (<methodname>regenerateId()</methodname>).
  288. The attacker then uses the new session id in combination with an XSS vulnerability, or injects the
  289. session id via a link on the attacker's website (works if <code>use_only_cookies = off</code>).
  290. </para>
  291. <para>
  292. If you can distinguish between an attacker and victim using the same session id, then session hijacking
  293. can be dealt with directly. However, such distinctions usually involve some form of usability tradeoffs,
  294. because the methods of distinction are often imprecise. For example, if a request is received from an IP
  295. in a different country than the IP of the request when the session was created, then the new request
  296. probably belongs to an attacker. Under the following conditions, there might not be any way for a
  297. website application to distinguish between a victim and an attacker:
  298. <itemizedlist mark='opencircle'>
  299. <listitem>
  300. <para>
  301. attacker first initiates a session on your website to obtain a valid session id
  302. </para>
  303. </listitem>
  304. <listitem>
  305. <para>
  306. attacker uses XSS vulnerability on your website to create a cookie on the victim's browser
  307. with the same, valid session id (i.e. session fixation)
  308. </para>
  309. </listitem>
  310. <listitem>
  311. <para>
  312. both the victim and attacker originate from the same proxy farm (e.g. both are behind the
  313. same firewall at a large company, like AOL)
  314. </para>
  315. </listitem>
  316. </itemizedlist>
  317. The sample code below makes it much harder for an attacker to know the current victim's session id,
  318. unless the attacker has already performed the first two steps above.
  319. </para>
  320. <example id="zend.session.global_session_management.session_identifiers.hijacking_and_fixation.example">
  321. <title>Session Fixation</title>
  322. <programlisting language="php"><![CDATA[
  323. $defaultNamespace = new Zend_Session_Namespace();
  324. if (!isset($defaultNamespace->initialized)) {
  325. Zend_Session::regenerateId();
  326. $defaultNamespace->initialized = true;
  327. }
  328. ]]></programlisting>
  329. </example>
  330. </sect3>
  331. </sect2>
  332. <sect2 id="zend.session.global_session_management.rememberme">
  333. <title>rememberMe(integer $seconds)</title>
  334. <para>
  335. Ordinarily, sessions end when the user agent terminates, such as when an end user exits a web browser
  336. program. However, your application may provide the ability to extend user sessions beyond the lifetime of
  337. the client program through the use of persistent cookies. Use <methodname>Zend_Session::rememberMe()</methodname> before
  338. a session is started to control the length of time before a persisted session cookie expires. If you do not
  339. specify a number of seconds, then the session cookie lifetime defaults to <code>remember_me_seconds</code>,
  340. which may be set using <methodname>Zend_Session::setOptions()</methodname>. To help thwart session fixation/hijacking,
  341. use this function when a user successfully authenticates with your application (e.g., from a "login" form).
  342. </para>
  343. </sect2>
  344. <sect2 id="zend.session.global_session_management.forgetme">
  345. <title>forgetMe()</title>
  346. <para>
  347. This function complements <methodname>rememberMe()</methodname> by writing a session cookie that has a lifetime ending
  348. when the user agent terminates.
  349. </para>
  350. </sect2>
  351. <sect2 id="zend.session.global_session_management.sessionexists">
  352. <title>sessionExists()</title>
  353. <para>
  354. Use this method to determine if a session already exists for the current user agent/request. It may be used
  355. before starting a session, and independently of all other <classname>Zend_Session</classname> and
  356. <classname>Zend_Session_Namespace</classname> methods.
  357. </para>
  358. </sect2>
  359. <sect2 id="zend.session.global_session_management.destroy">
  360. <title>destroy(bool $remove_cookie = true, bool $readonly = true)</title>
  361. <para>
  362. <methodname>Zend_Session::destroy()</methodname> destroys all of the persistent data associated with the current
  363. session. However, no variables in <acronym>PHP</acronym> are affected, so your namespaced sessions (instances of
  364. <classname>Zend_Session_Namespace</classname>) remain readable. To complete a "logout", set the optional parameter to
  365. <constant>TRUE</constant> (the default) to also delete the user agent's session id cookie. The optional
  366. <varname>$readonly</varname> parameter removes the ability to create new <classname>Zend_Session_Namespace</classname>
  367. instances and for <classname>Zend_Session</classname> methods to write to the session data store.
  368. </para>
  369. <para>
  370. If you see the error message, "Cannot modify header information - headers already sent", then either avoid
  371. using <constant>TRUE</constant> as the value for the first argument (requesting removal of the session cookie), or
  372. see <xref linkend="zend.session.global_session_management.headers_sent" />. Thus,
  373. <methodname>Zend_Session::destroy(true)</methodname> must either be called before <acronym>PHP</acronym> has sent <acronym>HTTP</acronym> headers, or output
  374. buffering must be enabled. Also, the total output sent must not exceed the set buffer size, in order to
  375. prevent triggering sending the output before the call to <methodname>destroy()</methodname>.
  376. </para>
  377. <note>
  378. <title>Throws</title>
  379. <para>
  380. By default, <varname>$readonly</varname> is enabled and further actions involving writing to the session data
  381. store will throw an exception.
  382. </para>
  383. </note>
  384. </sect2>
  385. <sect2 id="zend.session.global_session_management.stop">
  386. <title>stop()</title>
  387. <para>
  388. This method does absolutely nothing more than toggle a flag in <classname>Zend_Session</classname> to prevent further writing to
  389. the session data store. We are specifically requesting feedback on this feature. Potential uses/abuses might
  390. include temporarily disabling the use of <classname>Zend_Session_Namespace</classname> instances or
  391. <classname>Zend_Session</classname> methods to write to the session data store, while execution is transferred to view-
  392. related code. Attempts to perform actions involving writes via these instances or methods will throw an
  393. exception.
  394. </para>
  395. </sect2>
  396. <sect2 id="zend.session.global_session_management.writeclose">
  397. <title>writeClose($readonly = true)</title>
  398. <para>
  399. Shutdown the session, close writing and detach <varname>$_SESSION</varname> from the back-end storage mechanism.
  400. This will complete the internal data transformation on this request. The optional <varname>$readonly</varname>
  401. boolean parameter can remove write access by throwing an exception upon any attempt to write to the session
  402. via <classname>Zend_Session</classname> or <classname>Zend_Session_Namespace</classname>.
  403. </para>
  404. <note>
  405. <title>Throws</title>
  406. <para>
  407. By default, <varname>$readonly</varname> is enabled and further actions involving writing to the session data
  408. store will throw an exception. However, some legacy application might expect <varname>$_SESSION</varname> to
  409. remain writable after ending the session via <methodname>session_write_close()</methodname>. Although not considered
  410. "best practice", the <varname>$readonly</varname> option is available for those who need it.
  411. </para>
  412. </note>
  413. </sect2>
  414. <sect2 id="zend.session.global_session_management.expiresessioncookie">
  415. <title>expireSessionCookie()</title>
  416. <para>
  417. This method sends an expired session id cookie, causing the client to delete the session cookie. Sometimes
  418. this technique is used to perform a client-side logout.
  419. </para>
  420. </sect2>
  421. <sect2 id="zend.session.global_session_management.savehandler">
  422. <title>setSaveHandler(Zend_Session_SaveHandler_Interface $interface)</title>
  423. <para>
  424. Most developers will find the default save handler sufficient. This method provides an object-oriented
  425. wrapper for
  426. <ulink url="http://php.net/session_set_save_handler"><methodname>session_set_save_handler()</methodname></ulink>.
  427. </para>
  428. </sect2>
  429. <sect2 id="zend.session.global_session_management.namespaceisset">
  430. <title>namespaceIsset($namespace)</title>
  431. <para>
  432. Use this method to determine if a session namespace exists, or if a particular index exists in a particular
  433. namespace.
  434. </para>
  435. <note>
  436. <title>Throws</title>
  437. <para>
  438. An exception will be thrown if <classname>Zend_Session</classname> is not marked as readable (e.g., before
  439. <classname>Zend_Session</classname> has been started).
  440. </para>
  441. </note>
  442. </sect2>
  443. <sect2 id="zend.session.global_session_management.namespaceunset">
  444. <title>namespaceUnset($namespace)</title>
  445. <para>
  446. Use <methodname>Zend_Session::namespaceUnset($namespace)</methodname> to efficiently remove an entire namespace and its
  447. contents. As with all arrays in <acronym>PHP</acronym>, if a variable containing an array is unset, and the array contains
  448. other objects, those objects will remain available, if they were also stored by reference in other
  449. array/objects that remain accessible via other variables. So <methodname>namespaceUnset()</methodname> does not perform
  450. a "deep" unsetting/deleting of the contents of the entries in the namespace. For a more detailed
  451. explanation, please see <ulink url="http://php.net/references">References Explained</ulink> in the <acronym>PHP</acronym>
  452. manual.
  453. </para>
  454. <note>
  455. <title>Throws</title>
  456. <para>
  457. An exception will be thrown if the namespace is not writable (e.g., after <methodname>destroy()</methodname>).
  458. </para>
  459. </note>
  460. </sect2>
  461. <sect2 id="zend.session.global_session_management.namespaceget">
  462. <title>namespaceGet($namespace)</title>
  463. <para>
  464. DEPRECATED: Use <methodname>getIterator()</methodname> in <classname>Zend_Session_Namespace</classname>. This method returns an
  465. array of the contents of <varname>$namespace</varname>. If you have logical reasons to keep this method publicly
  466. accessible, please provide feedback to the
  467. <ulink url="mailto:fw-auth@lists.zend.com">fw-auth@lists.zend.com</ulink> mail list. Actually, all
  468. participation on any relevant topic is welcome :)
  469. </para>
  470. <note>
  471. <title>Throws</title>
  472. <para>
  473. An exception will be thrown if <classname>Zend_Session</classname> is not marked as readable (e.g., before
  474. <classname>Zend_Session</classname> has been started).
  475. </para>
  476. </note>
  477. </sect2>
  478. <sect2 id="zend.session.global_session_management.getiterator">
  479. <title>getIterator()</title>
  480. <para>
  481. Use <methodname>getIterator()</methodname> to obtain an array containing the names of all namespaces.
  482. </para>
  483. <note>
  484. <title>Throws</title>
  485. <para>
  486. An exception will be thrown if <classname>Zend_Session</classname> is not marked as readable (e.g., before
  487. <classname>Zend_Session</classname> has been started).
  488. </para>
  489. </note>
  490. </sect2>
  491. </sect1>