0
I am facing the following error while running my app:
Error Number: 1062
Duplicate entry '1484918130' for key 'PRIMARY'
INSERT INTO sistema_session
(id
, ip_address
, timestamp
, data
) VALUES ('5bb80caf2df687b3d36def267b95400f82e209b1', '200.103.171.165', 1484918130, '__ci_last_regenerate|i:1484918130;Identity|s:19: "[email protected] ";email|s:19: "[email protected] ";user_id|s:2: "24 ";old_last_login|s:10: "1484917031 ";username|s:8: "Jeronimo ";id_empresa|s:2: "14 ";typMenu|s:1: "1 ";')
Filename: Libraries/Session/drivers/Session_database_driver.php
Line Number: 233
I’m using Codeigniter, CI Session and I’m using Ionauth.
I have other systems using the same structure and does not present this error.
Someone’s been through it?
Your fault is not in the
session
, is in the bank. Thetimestamp
is the primary key, cannot be repeated. What bank is this?– ShutUpMagda
I am using mysql
– Clayton Eduardo Mergulhão
If there’s a function creating this data to enter into the database, it’s better to show. Error indicates that vc is trying to pass repeated values to a primary key of the bank.
– ShutUpMagda
More how can I fix this because I haven’t changed anything in the ionauth library
– Clayton Eduardo Mergulhão
If the library is generating this data with this failure, then you have two options: either study the documentation more deeply and find a way to prevent this from happening, or abandon the use of this library. In particular, I’ve never found anyone complaining about it, including, there’s a lot of material teaching to use (see).
– ShutUpMagda
I use the same library on another server and it works perfectly.
– Clayton Eduardo Mergulhão
A guess: the library seems to use timestamp to generate the keys. The fact is that the generated timestams are repeating from time to time. This is a symptom of wrong time on the server. Understand: if the server does not have a setting that adjusts the time, it may be passing wrong timestamp to the library, and it is repeating the timestamp and trying to write to the database, which returns its error.
– ShutUpMagda
Try to synchronize your server clock and make the date always correct to avoid these things (NTP help). Another advice would be to define the
Default timezone
PHP (what can be done withdate_default_timezone_set()
).– ShutUpMagda