@@ -358,8 +358,8 @@ same way:
358
358
unusable during the same request after you destroy the session.
359
359
360
360
You may also use the ``stop() `` method to completely kill the session
361
- by removing the old session_id , destroying all data, and destroying
362
- the cookie that contained the session id :
361
+ by removing the old session ID , destroying all data, and destroying
362
+ the cookie that contained the session ID :
363
363
364
364
.. literalinclude :: sessions/038.php
365
365
@@ -390,26 +390,35 @@ all of the options and their effects.
390
390
You'll find the following Session related preferences in your
391
391
**app/Config/App.php ** file:
392
392
393
- ============================== ============================================ ================================================= ============================================================================================
394
- Preference Default Options Description
395
- ============================== ============================================ ================================================= ============================================================================================
396
- **sessionDriver ** CodeIgniter\\ Session\\ Handlers\\ FileHandler CodeIgniter\\ Session\\ Handlers\\ FileHandler The session storage driver to use.
397
- CodeIgniter\\ Session\\ Handlers\\ DatabaseHandler
398
- CodeIgniter\\ Session\\ Handlers\\ MemcachedHandler
399
- CodeIgniter\\ Session\\ Handlers\\ RedisHandler
400
- CodeIgniter\\ Session\\ Handlers\\ ArrayHandler
401
- **sessionCookieName ** ci_session [A-Za-z\_ -] characters only The name used for the session cookie.
402
- **sessionExpiration ** 7200 (2 hours) Time in seconds (integer) The number of seconds you would like the session to last.
403
- If you would like a non-expiring session (until browser is closed) set the value to zero: 0
404
- **sessionSavePath ** null None Specifies the storage location, depends on the driver being used.
405
- **sessionMatchIP ** false true/false (boolean) Whether to validate the user's IP address when reading the session cookie.
406
- Note that some ISPs dynamically changes the IP, so if you want a non-expiring session you
407
- will likely set this to false.
408
- **sessionTimeToUpdate ** 300 Time in seconds (integer) This option controls how often the session class will regenerate itself and create a new
409
- session ID. Setting it to 0 will disable session ID regeneration.
410
- **sessionRegenerateDestroy ** false true/false (boolean) Whether to destroy session data associated with the old session ID when auto-regenerating
411
- the session ID. When set to false, the data will be later deleted by the garbage collector.
412
- ============================== ============================================ ================================================= ============================================================================================
393
+ ============================== ================== =========================== ============================================================
394
+ Preference Default Options Description
395
+ ============================== ================== =========================== ============================================================
396
+ **sessionDriver ** FileHandler::class FileHandler::class The session storage driver to use.
397
+ DatabaseHandler::class All the session drivers are located in the
398
+ MemcachedHandler::class ``CodeIgniter\Session\Handlers\ `` namespace.
399
+ RedisHandler::class
400
+ ArrayHandler::class
401
+ **sessionCookieName ** ci_session [A-Za-z\_ -] characters only The name used for the session cookie.
402
+ The value will be included in the key of the
403
+ Database/Memcached/Redis session records. So, set the value
404
+ so that it does not exceed the maximum length of the key.
405
+ **sessionExpiration ** 7200 (2 hours) Time in seconds (integer) The number of seconds you would like the session to last.
406
+ If you would like a non-expiring session (until browser is
407
+ closed) set the value to zero: 0
408
+ **sessionSavePath ** null None Specifies the storage location, depends on the driver being
409
+ used.
410
+ **sessionMatchIP ** false true/false (boolean) Whether to validate the user's IP address when reading the
411
+ session cookie. Note that some ISPs dynamically changes the IP,
412
+ so if you want a non-expiring session you will likely set this
413
+ to false.
414
+ **sessionTimeToUpdate ** 300 Time in seconds (integer) This option controls how often the session class will
415
+ regenerate itself and create a new session ID. Setting it to 0
416
+ will disable session ID regeneration.
417
+ **sessionRegenerateDestroy ** false true/false (boolean) Whether to destroy session data associated with the old
418
+ session ID when auto-regenerating
419
+ the session ID. When set to false, the data will be later
420
+ deleted by the garbage collector.
421
+ ============================== ================== =========================== ============================================================
413
422
414
423
.. note :: As a last resort, the Session library will try to fetch PHP's
415
424
session related INI settings, as well as legacy CI settings such as
@@ -498,9 +507,9 @@ permissions will probably break your application.
498
507
Instead, you should do something like this, depending on your environment
499
508
::
500
509
501
- mkdir /<path to your application directory>/Writable /sessions/
502
- chmod 0700 /<path to your application directory>/Writable /sessions/
503
- chown www-data /<path to your application directory>/Writable /sessions/
510
+ > mkdir /<path to your application directory>/writable /sessions/
511
+ > chmod 0700 /<path to your application directory>/writable /sessions/
512
+ > chown www-data /<path to your application directory>/writable /sessions/
504
513
505
514
Bonus Tip
506
515
---------
@@ -518,6 +527,8 @@ In addition, if performance is your only concern, you may want to look
518
527
into using `tmpfs <https://eddmann.com/posts/storing-php-sessions-file-caches-in-memory-using-tmpfs/ >`_,
519
528
(warning: external resource), which can make your sessions blazing fast.
520
529
530
+ .. _sessions-databasehandler-driver :
531
+
521
532
DatabaseHandler Driver
522
533
======================
523
534
@@ -561,6 +572,10 @@ For PostgreSQL::
561
572
562
573
CREATE INDEX "ci_sessions_timestamp" ON "ci_sessions" ("timestamp");
563
574
575
+ .. note :: The ``id`` value contains the session cookie name (``Config\App::$sessionCookieName``)
576
+ and the session ID and a delimiter. It should be increased as needed, for example,
577
+ when using long session IDs.
578
+
564
579
You will also need to add a PRIMARY KEY **depending on your 'sessionMatchIP'
565
580
setting **. The examples below work both on MySQL and PostgreSQL::
566
581
@@ -595,6 +610,8 @@ when it generates the code.
595
610
done processing session data if you're having performance
596
611
issues.
597
612
613
+ .. _sessions-redishandler-driver :
614
+
598
615
RedisHandler Driver
599
616
===================
600
617
@@ -631,6 +648,8 @@ sufficient:
631
648
632
649
.. literalinclude :: sessions/041.php
633
650
651
+ .. _sessions-memcachedhandler-driver :
652
+
634
653
MemcachedHandler Driver
635
654
=======================
636
655
0 commit comments