From 2ca826b0888096d3ab252cb642975dcc1e57ceab Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 22 Jun 2011 06:51:10 -0500 Subject: completed doc change for user_agent length increase --- user_guide/libraries/sessions.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide/libraries/sessions.html') diff --git a/user_guide/libraries/sessions.html b/user_guide/libraries/sessions.html index bb8f1fc9b..2154a773b 100644 --- a/user_guide/libraries/sessions.html +++ b/user_guide/libraries/sessions.html @@ -105,7 +105,7 @@ even add your own data to a user's session, but the process of reading, writing, -- cgit v1.2.3-24-g4f1b From 37f4b9caa02783e06dd7c5318200113409a0deb1 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 1 Jul 2011 17:56:50 -0500 Subject: backed out 648b42a75739, which was a NON-trivial whitespace commit. It broke the Typography class's string replacements, for instance --- user_guide/libraries/sessions.html | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'user_guide/libraries/sessions.html') diff --git a/user_guide/libraries/sessions.html b/user_guide/libraries/sessions.html index bb8f1fc9b..a6f3c601c 100644 --- a/user_guide/libraries/sessions.html +++ b/user_guide/libraries/sessions.html @@ -61,7 +61,7 @@ Session Class

The Session class permits you maintain a user's "state" and track their activity while they browse your site. The Session class stores session information for each user as serialized (and optionally encrypted) data in a cookie. It can also store the session data in a database table for added security, as this permits the session ID in the -user's cookie to be matched against the stored session ID. By default only the cookie is saved. If you choose to +user's cookie to be matched against the stored session ID. By default only the cookie is saved. If you choose to use the database option you'll need to create the session table as indicated below.

@@ -93,8 +93,8 @@ will cause it to read, create, and update sessions.

If sessions data does not exist (or if it has expired) a new session will be created and saved in the cookie. If a session does exist, its information will be updated and the cookie will be updated. With each update, the session_id will be regenerated.

-

It's important for you to understand that once initialized, the Session class runs automatically. There is nothing -you need to do to cause the above behavior to happen. You can, as you'll see below, work with session data or +

It's important for you to understand that once initialized, the Session class runs automatically. There is nothing +you need to do to cause the above behavior to happen. You can, as you'll see below, work with session data or even add your own data to a user's session, but the process of reading, writing, and updating a session is automatic.

@@ -106,7 +106,7 @@ even add your own data to a user's session, but the process of reading, writing,
  • The user's unique Session ID (this is a statistically random string with very strong entropy, hashed with MD5 for portability, and regenerated (by default) every five minutes)
  • The user's IP Address
  • The user's User Agent data (the first 50 characters of the browser data string)
  • -
  • The "last activity" time stamp.
  • +
  • The "last activity" time stamp.
  • The above data is stored in a cookie as a serialized array with this prototype:

    @@ -124,7 +124,7 @@ making the data highly secure and impervious to being read or altered by someone can be found here, although the Session class will take care of initializing and encrypting the data automatically.

    -

    Note: Session cookies are only updated every five minutes by default to reduce processor load. If you repeatedly reload a page +

    Note: Session cookies are only updated every five minutes by default to reduce processor load. If you repeatedly reload a page you'll notice that the "last activity" time only updates if five minutes or more has passed since the last time the cookie was written. This time is configurable by changing the $config['sess_time_to_update'] line in your system/config/config.php file.

    @@ -134,7 +134,7 @@ the cookie was written. This time is configurable by changing the $config['sess_ $this->session->userdata('item'); -

    Where item is the array index corresponding to the item you wish to fetch. For example, to fetch the session ID you +

    Where item is the array index corresponding to the item you wish to fetch. For example, to fetch the session ID you will do this:

    $session_id = $this->session->userdata('session_id'); @@ -145,7 +145,7 @@ will do this:

    Adding Custom Session Data

    A useful aspect of the session array is that you can add your own data to it and it will be stored in the user's cookie. -Why would you want to do this? Here's one example:

    +Why would you want to do this? Here's one example:

    Let's say a particular user logs into your site. Once authenticated, you could add their username and email address to the session cookie, making that data globally available to you without @@ -155,7 +155,7 @@ having to run a database query when you need it.

    $this->session->set_userdata($array); -

    Where $array is an associative array containing your new data. Here's an example:

    +

    Where $array is an associative array containing your new data. Here's an example:

    $newdata = array(
    @@ -167,7 +167,7 @@ having to run a database query when you need it.

    $this->session->set_userdata($newdata);

    If you want to add userdata one value at a time, set_userdata() also supports this syntax.

    $this->session->set_userdata('some_name', 'some_value');

    -

    Note: Cookies can only hold 4KB of data, so be careful not to exceed the capacity. The +

    Note: 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.

    Retrieving All Session Data

    @@ -179,10 +179,10 @@ encryption process in particular produces a longer data string than the original
     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
    +    [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
     )
     
    @@ -206,20 +206,20 @@ $this->session->unset_userdata($array_items);

    $this->session->keep_flashdata('item');

    Saving Session Data to a Database

    While the session data array stored in the user's cookie contains a Session ID, -unless you store session data in a database there is no way to validate it. For some applications that require little or no -security, session ID validation may not be needed, but if your application requires security, validation is mandatory. Otherwise, an old session +unless you store session data in a database there is no way to validate it. For some applications that require little or no +security, session ID validation may not be needed, but if your application requires security, validation is mandatory. Otherwise, an old session could be restored by a user modifying their cookies.

    When session data is available in a database, every time a valid session is found in the user's cookie, a database -query is performed to match it. If the session ID does not match, the session is destroyed. Session IDs can never +query is performed to match it. If the session ID does not match, the session is destroyed. Session IDs can never be updated, they can only be generated when a new session is created.

    -

    In order to store sessions, you must first create a database table for this purpose. Here is the basic +

    In order to store sessions, you must first create a database table for this purpose. Here is the basic prototype (for MySQL) required by the session class: