Session variable in sql Query

I wanted to use Session value in Sql parameter as dynamic value
I'm getting value in session Storage


Now the problem is how to use it,i treid session and read through Docs but no success

There is a huge difference between client-side sessions and server-side sessions.

  1. Client-side Sessions: Session data is stored on the user's device, typically in the form of browser cookies or local storage.
  2. Server-Side Sessions: Session data is stored on the server, and the client typically only retains a session identifier (e.g., a session ID in a cookie) to retrieve the associated data from the server.

In other words, if you want to use client-side sessions, you will need to post or get the values to the server.

Choosing $_SESSION on the server is not the same.

I understand the issue, but I'm confused about the solution. I checked the documentation, but I'm still unsure what the correct solution is.

What are you trying to do?

Why a session variable?

what i am trying to achieve is after login ,
i've created a session in which user id is store
then tried to fetch the user id in the sql query in order to fetch the request from database to get details of userID

Have a look at

In particular 02:16 Create a global Security Identity