summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Aker <greg.aker@ellislab.com>2011-04-18 18:18:09 +0200
committerGreg Aker <greg.aker@ellislab.com>2011-04-18 18:18:09 +0200
commit3403366d0f457c1dd449076b4177d1aff5cb176c (patch)
tree74b002b1cf7c8f12da195e8893f036b3b916aec7
parent62df13125bd9ab22ff0c7f2565a42a6de13ed7e4 (diff)
changeset: 2202:06a75a1bd622
tag: tip user: Greg Aker <greg.aker@ellislab.com> date: Mon Apr 18 11:10:37 2011 -0500 summary: Tweak to session class all_userdata() to just return the userdata array. Also documented previously undocumented all_userdata() method.
-rw-r--r--system/libraries/Session.php4
-rw-r--r--user_guide/libraries/sessions.html17
2 files changed, 19 insertions, 2 deletions
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 182294059..32317c2e6 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -435,11 +435,11 @@ class CI_Session {
* Fetch all session data
*
* @access public
- * @return mixed
+ * @return array
*/
function all_userdata()
{
- return ( ! isset($this->userdata)) ? FALSE : $this->userdata;
+ return $this->userdata;
}
// --------------------------------------------------------------------
diff --git a/user_guide/libraries/sessions.html b/user_guide/libraries/sessions.html
index 600d301c9..8d9c14eb6 100644
--- a/user_guide/libraries/sessions.html
+++ b/user_guide/libraries/sessions.html
@@ -170,6 +170,23 @@ having to run a database query when you need it.</p>
<p class="important"><strong>Note:</strong> Cookies can only hold 4KB of data, so be careful not to exceed the capacity. The
encryption process in particular produces a longer data string than the original so keep careful track of how much data you are storing.</p>
+<h2>Retrieving All Session Data</h2>
+<p>An array of all userdata can be retrieved as follows:</p>
+<code>$this-&gt;session-&gt;all_userdata()</code>
+
+<p>And returns an associative array like the following:</p>
+
+<pre>
+Array
+(
+ [session_id] => 4a5a5dca22728fb0a84364eeb405b601
+ [ip_address] => 127.0.0.1
+ [user_agent] => Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7;
+ [last_activity] => 1303142623
+)
+</pre>
+
+
<h2>Removing Session Data</h2>
<p>Just as set_userdata() can be used to add information into a session, unset_userdata() can be used to remove it, by passing the session key. For example, if you wanted to remove 'some_name' from your session information: </p>
<p><code>$this-&gt;session-&gt;unset_userdata('some_name');</code></p>