【发布时间】:2014-07-03 18:29:26
【问题描述】:
我正在使用 php 和 node.js 开发一个项目。我在会话中有一些数据,例如
[user]= ARRAY([0]=> stdClass Object([username] => XXX, [app_id] -> XXX))
现在我想从 session 中读取 app_id 并且需要在 node.js 中使用
var myquery =
"SELECT count(cs.id ) AS new_message " +
"FROM dcms_corr_status as cs " +
"LEFT JOIN `dcms_user` as u ON `u`.`appointment_ref_no` = `cs`.`appointment_ref_no` "+
"WHERE `cs`.`appointment_ref_no` = '" + user_app +"' AND `cs`.`isread` = 0 " +
"AND `cs`.`action_or_info` = 1";
var query = connection.query(myquery),
user_app 是我的会话数据。
我该怎么做?
【问题讨论】:
-
您需要为会话存储使用外部数据库/缓存,例如 Redis 或 Memcached。让 PHP 存储会话数据并使用 Node 检索它。
-
可能还想将其编码为 JSON,以便节点更好地理解它。
-
此解决方案可能对您有所帮助:stackoverflow.com/a/51754896/1274820