@@ -29,9 +29,7 @@ The ``$config`` parameter is optional - your application configuration.
2929If not provided, the services register will instantiate your default
3030one.
3131
32- Once loaded, the Sessions library object will be available using::
33-
34- $session
32+ Once loaded, the Sessions library object will be available using ``$session ``.
3533
3634Alternatively, you can use the helper function that will use the default
3735configuration options. This version is a little friendlier to read,
@@ -118,7 +116,8 @@ Retrieving Session Data
118116=======================
119117
120118Any piece of information from the session array is available through the
121- ``$_SESSION `` superglobal:
119+ ``$_SESSION `` superglobal. For example, to assign a previously stored ``name `` item to the ``$name ``
120+ variable, you will do this:
122121
123122.. literalinclude :: sessions/004.php
124123
@@ -134,12 +133,6 @@ Or even through the session helper method:
134133
135134.. literalinclude :: sessions/007.php
136135
137- Where ``item `` is the array key corresponding to the item you wish to fetch.
138- For example, to assign a previously stored ``name `` item to the ``$name ``
139- variable, you will do this:
140-
141- .. literalinclude :: sessions/008.php
142-
143136.. note :: The ``get()`` method returns null if the item you are trying
144137 to access does not exist.
145138
@@ -191,7 +184,7 @@ Pushing New Value to Session Data
191184=================================
192185
193186The ``push() `` method is used to push a new value onto a session value that is an array.
194- For instance, if the ``hobbies `` key contains an array of hobbies, you can add a new value onto the array like so:
187+ For instance, if the ``hobbies `` key contains an array of hobbies, you can add a new value or replace the previous value onto the array like so:
195188
196189.. literalinclude :: sessions/015.php
197190
@@ -397,21 +390,6 @@ All session data (including flashdata and tempdata) will be destroyed permanentl
397390.. note :: You do not have to call this method from usual code. Cleanup session
398391 data rather than destroying the session.
399392
400- .. _session-stop :
401-
402- stop()
403- ------
404-
405- .. deprecated :: 4.3.5
406-
407- The session class also has the ``stop() `` method.
408-
409- .. warning :: Prior to v4.3.5, this method did not destroy the session due to a bug.
410-
411- Starting with v4.3.5, this method has been modified to destroy the session.
412- However, it is deprecated because it is exactly the same as the ``destroy() ``
413- method. Use the ``destroy() `` method instead.
414-
415393Accessing Session Metadata
416394==========================
417395
@@ -453,7 +431,7 @@ Preference Default Opti
453431**cookieName ** ci_session [A-Za-z\_ -] characters only The name used for the session cookie.
454432**expiration ** 7200 (2 hours) Time in seconds (integer) The number of seconds you would like the session to last.
455433 If you would like a non-expiring session (until browser is closed) set the value to zero: 0
456- **savePath ** null None Specifies the storage location, depends on the driver being used.
434+ **savePath ** WRITEPATH . 'session' None Specifies the storage location, depends on the driver being used.
457435**matchIP ** false true/false (boolean) Whether to validate the user's IP address when reading the session cookie.
458436 Note that some ISPs dynamically changes the IP, so if you want a non-expiring session you
459437 will likely set this to false.
@@ -552,6 +530,10 @@ Instead, you should do something like this, depending on your environment:
552530 chmod 0700 /<path to your application directory>/writable/sessions/
553531 chown www-data /<path to your application directory>/writable/sessions/
554532
533+ Since the built-in mechanism does not have automatic cleaning of expired sessions,
534+ you will notice that the *saveDir * directory may overflow with files.
535+ To solve this problem, you will need to configure the **cron ** or **Task Scheduler ** to delete outdated files.
536+
555537Bonus Tip
556538---------
557539
@@ -608,10 +590,10 @@ And then of course, create the database table.
608590For MySQL::
609591
610592 CREATE TABLE IF NOT EXISTS `ci_sessions` (
611- `id` varchar(128) NOT null ,
612- `ip_address` varchar(45) NOT null ,
613- `timestamp` timestamp DEFAULT CURRENT_TIMESTAMP NOT null ,
614- `data` blob NOT null ,
593+ `id` varchar(128) NOT NULL ,
594+ `ip_address` varchar(45) NOT NULL ,
595+ `timestamp` timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL ,
596+ `data` blob NOT NULL ,
615597 KEY `ci_sessions_timestamp` (`timestamp`)
616598 );
617599
0 commit comments