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

Very strange.... Exceptions cause loss of user session when debugging is on. Is it Phalcon or is it me?

Hi,

I wonder if anyone else has encountered the following behaviour.

I use PHPEd remote debugger when developing. Every time when my application throws an exception and it is caught by PHPEd, AND I decide to terminate script execution, I lose user session.

If I let the execution continue, session is preserved.

Session is not lost when debugger is off and it does not matter if exception is left unhandled.

I have never seen anything similar in all my years dealing with remote debugging. So, my question is - could it be that Phalcon's session handler "forgets" the session variables when exception is thrown and execution is aborted from within the IDE?

Thanks, Temuri

Is it possible for you to see $_SESSION and $_COOKIE before and after the exception is thrown? Is it possible PHPEd is flushing $_SESSION or $_COOKIE?



51.4k

Yes, I can see both $_SESSION and $_COOKIE after an exception is thrown and execution is halted. I am absolutely positive that PHPEd does not flush any superglobals - I've been debugging Exceptions for a long time and never experienced anything similar. Clearly, it's something inside Phalcon extension.

I can reliably reproduce this behaviour, if anyone from development team wants to have a closer look.



98.9k

The only thing Phalcon does is update the _SESSION super-global when you call session->set/session->get, there is no way that Phalcon could affect a debugger behavior:

https://github.com/phalcon/cphalcon/blob/master/ext/session/adapter.c#L181 https://github.com/phalcon/cphalcon/blob/master/ext/session/adapter.c#L218