Share session ID from CLI to browser
Asked Answered
O

2

0

I have a websocket connection from the browser to a php script running as a websocket server on CLI.

I have the client send its session_id that was on the server i know which user has which session.

It works perfectly to read the $_SESSION of the individual users.

i do (on the server side [my CLI code]):

$sess_ini = ini_get('session.save_path');
$save = file_get_contents("$sess_ini/sess_$sessionID");
session_id($sessionID);
$sessions = explode("|",$save);
$_SESSION['values'] = (isset($sessions[1])?
                        unserialize(trim(urldecode($sessions[1]))):array());

Then when i manipulate $_SESSION['values'] on the CLI server side it does not get reflected on the client session and the session is not manipulated. how do i make it so the manipulated session is sent back to the client?

Thanks!

Outspoken answered 18/3, 2011 at 14:25 Comment(1)
How do you get the $sessionID?. I can't make it work.... The CLI sessionID is different from the Web sessionIDDivulsion
O
0

There was an error in my code.

The session was being saved, i just neglected to output it before it was changed so it looked like it never changed.

Outspoken answered 18/3, 2011 at 18:50 Comment(0)
V
0

You could write sessionId to users table in DB
And than in CLI and Web your must use this:

session_id($sessionFromDb);
Vulturine answered 18/3, 2011 at 14:31 Comment(3)
no no. i am able to get the session. thats fine. but changing it so that it reflects on the client side is not workingOutspoken
You could use this ru.php.net/session_write_close, or maybe no permissions to write session file?Vulturine
And, are you sure that in Web and CLI sessionId is no diffrent?Vulturine
O
0

There was an error in my code.

The session was being saved, i just neglected to output it before it was changed so it looked like it never changed.

Outspoken answered 18/3, 2011 at 18:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.