@@ -583,6 +583,9 @@ However, there are some conditions that must be met:
583583Configure DatabaseHandler
584584-------------------------
585585
586+ Setting Table Name
587+ ^^^^^^^^^^^^^^^^^^
588+
586589In order to use the 'DatabaseHandler' session driver, you must also create this
587590table that we already mentioned and then set it as your
588591``$savePath `` value.
@@ -591,6 +594,9 @@ you would do this:
591594
592595.. literalinclude :: sessions/039.php
593596
597+ Creating Database Table
598+ ^^^^^^^^^^^^^^^^^^^^^^^
599+
594600And then of course, create the database table ...
595601
596602For MySQL::
@@ -618,6 +624,9 @@ For PostgreSQL::
618624 and the session ID and a delimiter. It should be increased as needed, for example,
619625 when using long session IDs.
620626
627+ Adding Primary Key
628+ ^^^^^^^^^^^^^^^^^^
629+
621630You will also need to add a PRIMARY KEY **depending on your $matchIP
622631setting **. The examples below work both on MySQL and PostgreSQL::
623632
@@ -630,11 +639,23 @@ setting**. The examples below work both on MySQL and PostgreSQL::
630639 // To drop a previously created primary key (use when changing the setting)
631640 ALTER TABLE ci_sessions DROP PRIMARY KEY;
632641
633- You can choose the Database group to use by adding a new line to the
634- **app/Config/Session.php ** file with the name of the group to use:
642+ .. important :: If you don't add the correct primary key, the following error
643+ may occur::
644+
645+ Uncaught mysqli_sql_exception: Duplicate entry 'ci_session:***' for key 'ci_sessions.PRIMARY'
646+
647+ Changing Database Group
648+ ^^^^^^^^^^^^^^^^^^^^^^^
649+
650+ The default database group is used by default.
651+ You can change the database group to use by changing the ``$DBGroup `` property
652+ in the **app/Config/Session.php ** file to the name of the group to use:
635653
636654.. literalinclude :: sessions/040.php
637655
656+ Setting Up Database Table with Command
657+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
658+
638659If you'd rather not do all of this by hand, you can use the ``make:migration --session `` command
639660from the cli to generate a migration file for you::
640661
0 commit comments