php - How to find by user id specific user session using PdoSessionHandler in Symfony?

945

I'm using Symfony session management system with PdoSessionHandler and I need to find specific session entry using user id saved in session data.

Because manually searching every session blob data could be costly my idea is to add another column into sessions table to specifically store user_id so I can tie session entry to the user.

My question is how to achieve this using existing Session module?

Another important info is that I'm using standalone Session module outside Symfony framework.

Here is simplified code that I use for initializing session module:

new Session(
  new NativeSessionStorage([], new PdoSessionHandler(new PDO())), 
  new NamespacedAttributeBag()
)

People are also looking for solutions to the problem: javascript - HTML/PHP site communicating with discord bot

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.