@@ -559,6 +559,9 @@ However, there are some conditions that must be met:
559559Configure DatabaseHandler
560560-------------------------
561561
562+ Setting Table Name
563+ ^^^^^^^^^^^^^^^^^^
564+
562565In order to use the 'DatabaseHandler' session driver, you must also create this
563566table that we already mentioned and then set it as your
564567``$savePath `` value.
@@ -567,6 +570,9 @@ you would do this:
567570
568571.. literalinclude :: sessions/039.php
569572
573+ Creating Database Table
574+ ^^^^^^^^^^^^^^^^^^^^^^^
575+
570576And then of course, create the database table ...
571577
572578For MySQL::
@@ -594,6 +600,9 @@ For PostgreSQL::
594600 and the session ID and a delimiter. It should be increased as needed, for example,
595601 when using long session IDs.
596602
603+ Adding Primary Key
604+ ^^^^^^^^^^^^^^^^^^
605+
597606You will also need to add a PRIMARY KEY **depending on your $matchIP
598607setting **. The examples below work both on MySQL and PostgreSQL::
599608
@@ -606,11 +615,23 @@ setting**. The examples below work both on MySQL and PostgreSQL::
606615 // To drop a previously created primary key (use when changing the setting)
607616 ALTER TABLE ci_sessions DROP PRIMARY KEY;
608617
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:
611629
612630.. literalinclude :: sessions/040.php
613631
632+ Setting Up Database Table with Command
633+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
634+
614635If you'd rather not do all of this by hand, you can use the ``make:migration --session `` command
615636from the cli to generate a migration file for you::
616637
0 commit comments