Closed Reserford1991 closed 6 years ago
Are you redirecting after the login? Also what are your config settings for the session/cookies?
Hi. Yes, am being redirected after login. Here are my configs or session/cookies:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = false;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = false;
$config['cookie_prefix'] = 'serpfarm_';
$config['cookie_domain'] = '.' . $_SERVER['SERVER_NAME'];
$config['cookie_path'] = '/';
$config['cookie_secure'] = false;
$config['cookie_httponly'] = false;
Before this issue I had another problem. When I tried to login, I was getting this message from database:
Error Number: 1062
Duplicate entry '1508395728' for key 'PRIMARY'
INSERT INTO `ci_sessions` (`id`, `ip_address`, `timestamp`, `data`) VALUES ('q63dbs867jssnf397eo14fbdscevai3o', '127.0.0.1', 1508395728, '__ci_last_regenerate|i:1508395728;FBRLH_state|s:32:\"d60d072a1bf2fdd7a99d884cf389c1e3\";')
Filename: C:/OSPanel/domains/sitemanager/system/database/DB_driver.php
Line Number: 691
In database table ci_sessions I had timstamp column as primary key. After I made id column primary key, I managed to load login page, but now I have login loop after I enter correct login and password. I also noticed one interesting thing. When I load page, I get two records in ci_sesions table. I mother project, where I used Codeighniter, There was only one recording for each session. Maybe this is the real problem, which causes login loop.
Make sure it's not related to the code in the example controller that redirects the user if they arent an admin.
Ok. Thanks a lot, I'll see about that. Can this problem be related to .htaccess of my local server? I just took standard for codeighniter and used it on my website.
Maybe yea... Try adding the index.php and see if you get the same results.
Actually I already did that, but no result yet. As far I understood during today's debugging, somehow CI makes several records to database at the same time. Tomorrow I'll debug this problem and let you know about results. One more possible source of the problem is my OS - windows 7 (don't laugh too much). Hopefully tomorrow I'll switch back to Linux or Mac again.
By the way, one more question. On which version of PhP you made this plugin. If I use 7.1 or 7.0, won't it cause any problems?
I'm not aware of any issues in 7.x. You should see a PHP error if it's related to the version.
Ok. I'll try that too. Thanks a lot for valuable tips.
No problem!
@Reserford1991 please, also make sure you have latest version of CodeIgniter.
Any update?
Hi. I solved this problem. Solution was easy - just downgraded PHP to version 7.0.8 Before that I tried to work on version 7.1.8 Had problems with ci_session. Now those problems are gone. So I think you can close this issue now.
Thanks, closing.
What version of CodeIgniter were you on?
echo CI_VERSION gives me 3.1.0 but as I understood it is some issue with PHP itself and its bugs with session handling in latest versions.
If you get a chance to circle back to this I’d be interested in if PHP 7.1 works for you with CI3.1.6
I'm sure I will, because now I'm working with project, which uses your plugin. This product will be used by hundreds of users and no doubt that some them will use php 7.1.
Hello everybody I have a problem with login. I've been redirectred to login page in a loop. As far as I understood, smth is wrong with session and cookies, because flag of successful login is not transferred to session. Thanks in advance.