@@ -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
@@ -402,7 +395,7 @@ All session data (including flashdata and tempdata) will be destroyed permanentl
402395stop()
403396------
404397
405- .. deprecated :: 4 .3.5
398+ .. important :: This method was deprecated as of version v4 .3.5 and was removed in v4.7.0.
406399
407400The session class also has the ``stop() `` method.
408401
@@ -453,7 +446,7 @@ Preference Default Opti
453446**cookieName ** ci_session [A-Za-z\_ -] characters only The name used for the session cookie.
454447**expiration ** 7200 (2 hours) Time in seconds (integer) The number of seconds you would like the session to last.
455448 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.
449+ **savePath ** WRITEPATH . 'session' None Specifies the storage location, depends on the driver being used.
457450**matchIP ** false true/false (boolean) Whether to validate the user's IP address when reading the session cookie.
458451 Note that some ISPs dynamically changes the IP, so if you want a non-expiring session you
459452 will likely set this to false.
@@ -552,6 +545,10 @@ Instead, you should do something like this, depending on your environment:
552545 chmod 0700 /<path to your application directory>/writable/sessions/
553546 chown www-data /<path to your application directory>/writable/sessions/
554547
548+ Since the built-in mechanism does not have automatic cleaning of expired sessions,
549+ you will notice that the *saveDir * directory may overflow with files.
550+ To solve this problem, you will need to configure the **cron ** or **Task Scheduler ** to delete outdated files.
551+
555552Bonus Tip
556553---------
557554
@@ -608,10 +605,10 @@ And then of course, create the database table.
608605For MySQL::
609606
610607 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 ,
608+ `id` varchar(128) NOT NULL ,
609+ `ip_address` varchar(45) NOT NULL ,
610+ `timestamp` timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL ,
611+ `data` blob NOT NULL ,
615612 KEY `ci_sessions_timestamp` (`timestamp`)
616613 );
617614
0 commit comments