node.js socket.io php session whit redis和memcached

我有一个由PHP提供的网站,每个用户在登录时都有一个存储在php文件中的会话 in。</ p>

我的问题是:没有redis或memcached,可以从php文件到node.js服务器获取会话,如果没有,我怎么能用 redis是一个memcached?</ p>
</ div>

展开原文

原文

I have a site that is delivered by PHP and every user has a Session stored in a php file when he is logged in.

My Question is: it is possible, without redis or memcached, to get the session from the php file to the node.js server or if not, how can I do it with redis an memcached?

dousha2020
dousha2020 “每个用户都有一个存储在php文件中的会话”......你能详细说明一下吗?你正在编写自己的会话处理程序?而你正在编写PHP文件?
接近 6 年之前 回复

1个回答

No matter how you store your PHP sessions, if you want to share data with an outside application, it should be served up from your PHP application. This gives you the flexibility of changing your session handling later on, while avoiding writing some custom session data parsing code on your Node.js application.

<?php
session_id($_GET['sessionId']);
echo json_encode($_SESSION);

Then in your Node.js application, you can fetch /getSessionData.php?sessionId=0123456789abcdef or whatever. Note that you must lock this script down so that it is completely inaccessible except from your other applications. Otherwise, you would be opening yourself up to a nasty security hole. Also, if you aren't already rotating session IDs, you should re-write your session handler anyway so that it is hard to re-play requests with an old session ID.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐