Skip to content

Commit e5f321f

Browse files
authored
Merge pull request #7116 from kenjis/fix-docs-sessions
docs: fix sessions.rst
2 parents e30f5ee + 4f4e2f0 commit e5f321f

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

user_guide_src/source/libraries/sessions.rst

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,14 @@ into using `tmpfs <https://eddmann.com/posts/storing-php-sessions-file-caches-in
525525
DatabaseHandler Driver
526526
======================
527527

528+
.. important:: Only MySQL and PostgreSQL databases are officially
529+
supported, due to lack of advisory locking mechanisms on other
530+
platforms. Using sessions without locks can cause all sorts of
531+
problems, especially with heavy usage of AJAX, and we will not
532+
support such cases. Use ``session_write_close()`` after you've
533+
done processing session data if you're having performance
534+
issues.
535+
528536
The 'DatabaseHandler' driver uses a relational database such as MySQL or
529537
PostgreSQL to store sessions. This is a popular choice among many users,
530538
because it allows the developer easy access to the session data within
@@ -534,6 +542,9 @@ However, there are some conditions that must be met:
534542

535543
- You can NOT use a persistent connection.
536544

545+
Configure DatabaseHandler
546+
-------------------------
547+
537548
In order to use the 'DatabaseHandler' session driver, you must also create this
538549
table that we already mentioned and then set it as your
539550
``$savePath`` value.
@@ -569,7 +580,7 @@ For PostgreSQL::
569580
and the session ID and a delimiter. It should be increased as needed, for example,
570581
when using long session IDs.
571582

572-
You will also need to add a PRIMARY KEY **depending on your 'sessionMatchIP'
583+
You will also need to add a PRIMARY KEY **depending on your $matchIP
573584
setting**. The examples below work both on MySQL and PostgreSQL::
574585

575586
// When sessionMatchIP = true
@@ -592,17 +603,9 @@ from the cli to generate a migration file for you::
592603
> php spark make:migration --session
593604
> php spark migrate
594605

595-
This command will take the **savePath** and **matchIP** settings into account
606+
This command will take the ``$savePath`` and ``$matchIP`` settings into account
596607
when it generates the code.
597608

598-
.. important:: Only MySQL and PostgreSQL databases are officially
599-
supported, due to lack of advisory locking mechanisms on other
600-
platforms. Using sessions without locks can cause all sorts of
601-
problems, especially with heavy usage of AJAX, and we will not
602-
support such cases. Use ``session_write_close()`` after you've
603-
done processing session data if you're having performance
604-
issues.
605-
606609
.. _sessions-redishandler-driver:
607610

608611
RedisHandler Driver
@@ -623,6 +626,9 @@ bundled with PHP.
623626
Chances are, you're only be using the RedisHandler driver only if you're already
624627
both familiar with Redis and using it for other purposes.
625628

629+
Configure RedisHandler
630+
----------------------
631+
626632
Just as with the 'FileHandler' and 'DatabaseHandler' drivers, you must also configure
627633
the storage location for your sessions via the
628634
``$savePath`` setting.
@@ -632,7 +638,7 @@ link you to it:
632638

633639
https://github.com/phpredis/phpredis
634640

635-
.. warning:: CodeIgniter's Session library does NOT use the actual 'redis'
641+
.. important:::: CodeIgniter's Session library does NOT use the actual 'redis'
636642
``session.save_handler``. Take note **only** of the path format in
637643
the link above.
638644
@@ -665,6 +671,9 @@ deleted after Y seconds have passed (but not necessarily that it won't
665671
expire earlier than that time). This happens very rarely, but should be
666672
considered as it may result in loss of sessions.
667673

674+
Configure RedisHandler
675+
----------------------
676+
668677
The ``$savePath`` format is fairly straightforward here,
669678
being just a ``host:port`` pair:
670679

user_guide_src/source/libraries/sessions/039.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ class Session extends BaseConfig
99
{
1010
// ...
1111
public string $driver = 'CodeIgniter\Session\Handlers\DatabaseHandler';
12+
1213
// ...
1314
public string $savePath = 'ci_sessions';
15+
1416
// ...
1517
}

user_guide_src/source/libraries/sessions/041.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ class Session extends BaseConfig
99
{
1010
// ...
1111
public string $driver = 'CodeIgniter\Session\Handlers\RedisHandler';
12+
1213
// ...
1314
public string $savePath = 'tcp://localhost:6379';
15+
1416
// ...
1517
}

user_guide_src/source/libraries/sessions/042.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ class Session extends BaseConfig
99
{
1010
// ...
1111
public string $driver = 'CodeIgniter\Session\Handlers\MemcachedHandler';
12+
1213
// ...
1314
public string $savePath = 'localhost:11211';
15+
1416
// ...
1517
}

0 commit comments

Comments
 (0)