将会话ID从CLI共享到浏览器 [英] Share session ID from CLI to browser

查看:139
本文介绍了将会话ID从CLI共享到浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从浏览器到php脚本的websocket连接,该脚本在CLI上作为websocket服务器运行.

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

我让客户端发送它在服务器上的session_id,我知道哪个用户具有哪个会话.

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

它非常适合读取单个用户的$ _SESSION.

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

我愿意(在服务器端[我的CLI代码]):

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());

然后,当我在CLI服务器端操作$ _SESSION ['values']时,它不会反映在客户端会话上,并且不会对会话进行操作.我如何做到这一点,以便将受操纵的会话发送回客户端?

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?

谢谢!

推荐答案

我的代码有错误.

该会话已保存,在更改之前我只是忽略了它的输出,因此看起来它从未更改过.

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

这篇关于将会话ID从CLI共享到浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆