Welcome Guest, Not a member yet? Register   Sign In
Session data is slow to update on production server
#1

Hi, i've been looking for the solution to a session-related problem online but still not find any.

I'm using CI 4.1.8 and this is the server info on production:
cPanel Version 100.0 (build 7)
Apache Version 2.4.52
PHP Version 7.4.27
MySQL Version 5.7.37
Architecture x86_64
Operating System linux
Path to Sendmail /usr/sbin/sendmail
Path to Perl /usr/bin/perl
Perl Version 5.16.3
Kernel Version 3.10.0-962.3.2.lve1.5.52.el7.x86_64

They are working just fine in the dev server (localhost). Dev server uses same Apache and PHP version as production server.

The issue:
-I put $this->session = \Config\Services::session(); on BaseController. i call $this->session-> on controllers with no issue.
-When i do a login function and check whether username/pwd is correct, i set to session the username and set flashdata for login success notification and do redirect to homepage.
-I have menu section where if username is set it shows profile link, when not set it shows signup/login link.
-It works correctly on localhost, the redirected page contains flashdata and username is stored in session. when i click refresh immediately after, the flashdata disappear as intended and the menu changes accordingly.
-However, on production, when i click refresh immediately after redirect, the flashdata still persists. i have to wait around 10-15 seconds and hit refresh before changes in session is reflected.
-I try session_destroy(), and it's the same. i have to wait around 10-15 seconds and hit refresh before any changes related to session data is reflected.

I don't understand this behavior and since there's no error i don't know where to look at my code/setting.
Can someone help? many thanks.
Reply
#2

Did you try session_write_close() ?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

It turned out a server issue.
I don't know why but by default my hosting provider disables "nginx bypass cache" feature.
when i enable it, the app behaves like in localhost.
kind of weird because in the server info it show Apache (or maybe i wasn't understanding it correctly).

mark as solved~
Reply
#4

(02-07-2022, 03:57 AM)agahwibisana Wrote: It turned out a server issue.
I don't know why but by default my hosting provider disables "nginx bypass cache" feature.
when i enable it, the app behaves like in localhost.
kind of weird because in the server info it show Apache (or maybe i wasn't understanding it correctly).

mark as solved~

I am having an issue likewise yours. 
 Maybe I need to do something in server configurations? I use Apache
Reply




Theme © iAndrew 2016 - Forum software by © MyBB