[ci skip] Correct session database setup docs
diff --git a/application/config/config.php b/application/config/config.php
index a4d883f..479d591 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -344,6 +344,9 @@
|
| Whether to match the user's IP address when reading the session data.
|
+| WARNING: If you're using the database driver, don't forget to update
+| your session table's PRIMARY KEY when changing this setting.
+|
| 'sess_time_to_update'
|
| How many seconds between CI regenerating the session ID.
diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst
index 2034ed2..9c9761b 100644
--- a/user_guide_src/source/libraries/sessions.rst
+++ b/user_guide_src/source/libraries/sessions.rst
@@ -598,7 +598,6 @@
`ip_address` varchar(45) NOT NULL,
`timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
`data` blob NOT NULL,
- PRIMARY KEY (id),
KEY `ci_sessions_timestamp` (`timestamp`)
);
@@ -608,17 +607,23 @@
"id" varchar(40) NOT NULL,
"ip_address" varchar(45) NOT NULL,
"timestamp" bigint DEFAULT 0 NOT NULL,
- "data" text DEFAULT '' NOT NULL,
- PRIMARY KEY ("id")
+ "data" text DEFAULT '' NOT NULL
);
CREATE INDEX "ci_sessions_timestamp" ON "ci_sessions" ("timestamp");
-However, if you want to turn on the *sess_match_ip* setting, you should
-also do the following, after creating the table::
+You will also need to add a PRIMARY KEY **depending on your 'sess_match_ip'
+setting**. The examples below work both on MySQL and PostgreSQL::
- // Works both on MySQL and PostgreSQL
- ALTER TABLE ci_sessions ADD CONSTRAINT ci_sessions_id_ip UNIQUE (id, ip_address);
+ // When sess_match_ip = TRUE
+ ALTER TABLE ci_sessions ADD PRIMARY KEY (id, ip_address);
+
+ // When sess_match_ip = FALSE
+ ALTER TABLE ci_sessions ADD PRIMARY KEY (id);
+
+ // To drop a previously created primary key (use when changing the setting)
+ ALTER TABLE ci_sessions DROP PRIMARY KEY;
+
.. important:: Only MySQL and PostgreSQL databases are officially
supported, due to lack of advisory locking mechanisms on other