Two applications are developed with PHP and NodeJs respectively. how do these two applications share a session? Two applications are developed with PHP and NodeJs respectively. how do these two applications share a session?
Reply content:
Two applications are developed with PHP and NodeJs respectively. how do these two applications share a session?
Measure the test taker's understanding about the session mechanism.
- The client (in the browser) cookie acts as the key value and matches a data on the server. Then the client carries the cookie in the HTTP request each time, and the server "takes it for granted" that the data on the server is targeted at the client.
- Some systems like to encrypt session content and put it in cookies.
SO:
- You can share the cookie and place the data in nodejs and Sorry (PHP), such as redis. In the image, the default php session is written to his own file. So, you need to rewrite it at the same time.
- The two servers share a set of encryption and decryption methods, but it is not recommended.
The basic conditions for sharing the two are:
1. Save the cookie on the clientSession_id
The value of cookie name is the same
2. the server stores session data in shared storage media, such as databases and redis. Serialize and deserialize session values in the same way. For example, both are stored in json format.
Refer to this project: the https://gist.github.com/mscdex/9507b0d8df42e0aec825 givesPhp
AndNode. js
Sharing Solution. the storage solution used by php is redis-session-php.