Zend_Session-GlobalSessionManagement.xml 33 KB

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