CodeIgniter Forums
Cart Class Issue - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Cart Class Issue (/showthread.php?tid=72356)



Cart Class Issue - sourabh1992 - 12-10-2018

I Am Building an E-commerce Site Using Codeigniter 3. The site was Running fine until i faced a huge bug in the cart class of the system.

The CI Cart or Session Class Does  not Matches user ip address by default and also if there is anything in the session of cart  class from one ip address and if it remains as it is from that ip and someone else from another ip address adds something in the cart session... the old session data from the other ip gets included into the new users data


it seems to be a real issue or m i missing something???  Undecided Undecided


RE: Cart Class Issue - InsiteFX - 12-11-2018

Did you setup your session table correctly?

You may need to add a Primary Key etc;

Code:
For MySQL:

CREATE TABLE IF NOT EXISTS `ci_sessions` (
       `id` varchar(128) NOT NULL,
       `ip_address` varchar(45) NOT NULL,
       `timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
       `data` blob NOT NULL,
       KEY `ci_sessions_timestamp` (`timestamp`),
);

// 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;

Only MySQL and PostgreSQL databases are officially supported, due to lack of advisory locking mechanisms on other platforms.
Using sessions without locks can cause all sorts of problems, especially with heavy usage of AJAX, and we will not support
such cases. Use session_write_close() after you’ve done processing session data if you’re having performance issues.