Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB Session adapter corupts session data with Postgresql DB #961

Open
Maximskv opened this issue Feb 20, 2021 · 0 comments
Open

DB Session adapter corupts session data with Postgresql DB #961

Maximskv opened this issue Feb 20, 2021 · 0 comments
Assignees

Comments

@Maximskv
Copy link

Expected and Actual Behavior

When using the Db session adapter with Postgresql the session fails to be written and read properly.
The adapter serializes the session->data and tries to store the result in a text field. The serialized session->data text has null bytes. Postgresql is omitting everything after the first null byte resulting in cropped session->data that cannot be read, rendering the whole component unusable.

A quick dirty fix I have used to overcome the issue:

  1. Use a json type field for the data field in the DB session table.
  2. json_encode() the session->data prior to writing it to db (json_decode the data after reading it respectively ).

As demonstrated in this gist.

Steps to reproduce:

will add a demonstration project at a later point

  1. Use the DB session adapter with a Postgresql database
  2. Generate a new session.
  3. Try to read the generated session -> fails as the serialized session->data has been corrupted while being saved to the db.

Details

  • Phalcon Framework version: 4.0
  • Phalcon Incubator version: 1.1
  • PHP Version: 7.4
  • Operating System: maxOS
  • Server: Nginx | Apache
  • Other related info :
    • Database : Postgresql 13.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants