I am implementing web-socket server in php for my project. When a user will create websocket connection, it will send PHPSESSID cookie in request headers to the webserver page.
I want to fetch session data for every user using their PHPSESSID cookie value.
This server page can not fetch session value by simply using $_SESSION['name']
For every incoming socket connection, i fetch PHPSESSID
$cookie = handshake($header, $socket_new, $host, $port);
here handshake function will return PHPSESSID cookie.
session_id($cookie);
session_start();
$username = $_SESSION['name'];
For every websocket connection i am receiving right cookie but $username
only for first connection.
This php file is running in background and i have to authenticate users with their cookie but it seems that session_id($cookie);
is setting only once.
Is there any way to fetch session data for different PHPSESSID values on this single page.
As @grossvogel mention just using session_write_close()
function just before session_id()
function enable me to fetch values for different sessions using PHPSESSID cookie.
Now i can use different sessions within single page