I would like to understand why CI's session table structure has these three primary keys: session_id
, ip_address
and user_agent
.
CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(45) DEFAULT '0' NOT NULL,
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id, ip_address, user_agent),
KEY `last_activity_idx` (`last_activity`)
);
Please explain the most you can, also, I would like to hear suggestions to improve this structure. Why are ip_address
and user_agent
primary_keys, not just indexes? What's the difference?
Another info, this table adds a row to every user's access to the system, so, it is very bloated.
Edit: Another question that come to mind. Why would I care about user agent match?