0

We have a questionnaire with a product configurator and we are saving the configuration for the user with a session. Somehow the session is not working properly. For some users it's just not saving the session and the user can't see his final configuration. Rather get's in a loop, where he needs to start the questionnaire again. This does not seem browser related.

We use session_id() in PHP to get the session ID. We checked some users randomly and it's not always working properly. Usually removing the session folder solves this issue and it works again. But well this can't be the solution, since everybody elses session gets deleted.

It's difficult to track the issue, since it's not easy to recreate. But what we saw is, that this issue seems to occur, when we upload some changes to the website or theme. Could be an coincidence though. My feeling was, if somebody already had a session saved and we uploaded some changes, that the session is deleted and it's not saving again. But like I said, we could not recreate this.

We are using:

  • WP + WooCommerce
  • Custom Plugin for Questionnaire
  • AWS Server (Cloudways)
  • Cloudflare

Any ideas are appreciated!

1
  • WordPress doesn't use PHP sessions, and a lot of WP hosts don't work with PHP sessions. Likewise PHP sessions rely on a browser cookie that stores a session ID, and in an in memory data store to hold the session values. If your server environment isn't persistent e.g. a lambda server, relies on caching and CDNs, then it's highly unlikely your PHP sessions will ever work. have you considered using cookies instead? PHP Sessions need a cookie to be set to work so it can't be used to bypass GDPR, trackers policies, and cookie prompts
    – Tom J Nowell
    Commented Feb 24, 2021 at 9:40

1 Answer 1

0

Any caching solution will probably break sessions.

Try turning off all caching (as well as CloudFlare proxy for your IP address) and see if your code works. If you have a WordPress caching plugin - turn that off too. If your hosting provider does some caching - turn that off too.

After turning off all caching if your site works, then you'll have to either 1) find another solution not using PHP sessions (recommended), or 2) make sure you never cache your pages (not recommended).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.