We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Session lost in production enviroment

Hello there,

Our latest project has some issues about session.

Time to time. (we can't found any pattern or error code). Session was gone. We use phalcon more than a year in our other projects and we do not face this kind of problems.

On this time we save member db object in the session and update it regularly.

It was php-fpm with nginx and phalcon 2.0.6

Is there any suggestions

My best regards.



85.5k

where is session stored ?

if it is in File, do you have load balancer between multiple servers ?

check the session timeout settings ?



11.9k

Stored in files, we are behind cloudflare, single server, no exotic things, setups. Just plain old file based session.

One exception after login

$user = Members::findFirst($loginand$password);

we store $user object in session and use later, (let say update last time connected to server etc).



85.5k

maybe u missplaced

session_destroy() 

somewhere ?

i am new the phalcon, but it doesnt sounds like a framework problem to me. Find you session start/destroys, make a var_dump there and check if those functiuons are called corretcly as they should be.

If the problem goes deep, find where those session hashes are store. /tmp/php or whatever ( i dont remmeber the default place ). and see what is inside this directory. Because if the file disapear there is a session_destoy somewhere ( or maybe a crom job is cleaing those temp files ). If the files are there, and phalcon can't read the session, then the problem sohuld be inside the framework



11.9k

Ummm no there is no session_destroy() in the code.

We use phalcon di session->remove() to clear session data. in 2 areas.

1-) before the login form render 2-) logout action.

Anyway thanks for support. It seems one of those weird stuations.