Session Locked error when Debug mode is disabled

I’m stuck,

Just when we are launching our new website. We received this error.

“Cannot write to session … because it is not locked” But it’s only happens when the debug mode is set false.

What I’m doing wrong?

It fails on the production, local, testing and staging environments.

Please, Help

Hm, I can’t reproduce it in a fresh Starterkit.

What if you remove the debug option instead of setting it too false? But I assume you have to because you are using different config file for your different environments?

What is your Kirby version?

Hi, thanks for your reply.

Sure, I’m using multiple environments and I need to explicit set false in some environments due to security issues.

Im going to test removing it from the default config.php and set it to true on the testing environments only.

I think that it works for you in the started kit as the default behavior. I’m using the new Kirby->session() few times in a custom implementation of AWS Cognito for our large set of users, and on the previous version the session::set and session::get method was working fine.

Maybe I’m doing something wrong, but the rare thing here is that it only fails when debug is false.

I apréciate any help, thanks!

That would have been my next question…

Yes, that the error shows up only when setting debug to false seems strange. What do you mean with it worked with the previous version, Kirby 2 or Kirby 3?

I’m using Kirby 3.2.0

It worked fine on Kirby 2 using the session::set/get methods.

It does not work!! I removed the debug option from config files and the same error persists.

Hm, I have no idea what could be causing this. Simply setting and getting values to the session shouldn’t cause this.

Maybe @bastianallgeier, @lukasbestle or @distantnative know more.

Thanks I hope you guys can help me, that is the only thing I’m needing to publish.

That’s very strange. This error should only occur if the internal methods of the session implementation are called incorrectly. But this is not something you should be able to trigger with your custom code (as I said, those methods are internal).

That it worked in v2 doesn’t mean anything as the session implementation was completely rewritten in v3.

To debug this, I need a detailed backtrace of the error. If you have that from the error output, please post it here (please post the text, not a screenshot). If the error is displayed without backtrace, please insert the command debug_print_backtrace(); in this line before the exception is thrown and then post the output here.

Hey Guys!! I found the error! My bad totally.

The error is not related with the kirby()->session() but the the backtrace was mentioned ‘Session Locked…’.

So, many thanks for your fast support!!

Glad you found it. :slight_smile:

What was the issue exactly? I don’t really understand what you mean to be honest.