Home > Web Front-end > JS Tutorial > body text

PHP和NodeJs开发的应用如何共用Session_node.js

WBOY
Release: 2016-05-16 16:03:46
Original
1788 people have browsed it

首先了解下session的机制

客户端(浏览器中) cookie 作为键值,匹配服务器端的一个数据。然后客户端每次在 HTTP 请求里面带着那个 cookie,然后服务器端“理所当然”认为服务器端的这个数据是针对该客户端的。
某些系统喜欢把 session 内容编码后加密放在 cookie 里面

那么你可以

1.你可以共用 cookie,然后把数据放在 nodejs 和 拍黄片(Sorry,是PHP) 都可以取到的地方,例如 redis。影像中 php 默认的 session 是写他自己的文件的,So,你需要同时重写。

2.两个服务端共用一套加解密方式,不过不太建议。

以上上就是本文的全部内容了,希望大家能够喜欢。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!