@@ -559,6 +559,9 @@ However, there are some conditions that must be met:
559
559
Configure DatabaseHandler
560
560
-------------------------
561
561
562
+ Setting Table Name
563
+ ^^^^^^^^^^^^^^^^^^
564
+
562
565
In order to use the 'DatabaseHandler' session driver, you must also create this
563
566
table that we already mentioned and then set it as your
564
567
``$savePath `` value.
@@ -567,6 +570,9 @@ you would do this:
567
570
568
571
.. literalinclude :: sessions/039.php
569
572
573
+ Creating Database Table
574
+ ^^^^^^^^^^^^^^^^^^^^^^^
575
+
570
576
And then of course, create the database table ...
571
577
572
578
For MySQL::
@@ -594,6 +600,9 @@ For PostgreSQL::
594
600
and the session ID and a delimiter. It should be increased as needed, for example,
595
601
when using long session IDs.
596
602
603
+ Adding Primary Key
604
+ ^^^^^^^^^^^^^^^^^^
605
+
597
606
You will also need to add a PRIMARY KEY **depending on your $matchIP
598
607
setting **. The examples below work both on MySQL and PostgreSQL::
599
608
@@ -606,11 +615,23 @@ setting**. The examples below work both on MySQL and PostgreSQL::
606
615
// To drop a previously created primary key (use when changing the setting)
607
616
ALTER TABLE ci_sessions DROP PRIMARY KEY;
608
617
609
- You can choose the Database group to use by adding a new line to the
610
- **app/Config/Session.php ** file with the name of the group to use:
618
+ .. important :: If you don't add the correct primary key, the following error
619
+ may occur::
620
+
621
+ Uncaught mysqli_sql_exception: Duplicate entry 'ci_session:***' for key 'ci_sessions.PRIMARY'
622
+
623
+ Changing Database Group
624
+ ^^^^^^^^^^^^^^^^^^^^^^^
625
+
626
+ The default database group is used by default.
627
+ You can change the database group to use by changing the ``$DBGroup `` property
628
+ in the **app/Config/Session.php ** file to the name of the group to use:
611
629
612
630
.. literalinclude :: sessions/040.php
613
631
632
+ Setting Up Database Table with Command
633
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
634
+
614
635
If you'd rather not do all of this by hand, you can use the ``make:migration --session `` command
615
636
from the cli to generate a migration file for you::
616
637
0 commit comments