3
I have a dedicated Centos 6.5 server with Plesk Panel 12 installed, with multiple sites in php. I would like to develop a chat with Node.js and integrate it with some sites made in php. Except that this chat needs to recover some information from the user who is logged in Ex.: The user can only access the chat if he is logged in. What would be the best way to integrate the two things PHP + Node.js?
Solution:
I followed the suggestion of Lauro Moraes in this question: Integrate nodejs application to php site on different servers? , and did what Guilherme suggested. The client logs into the PHP site, the session data is saved in the database in case I used Redis. In the php part I request Node.js via the socket.io by sending the cookie with the session id. On Node.js I take this session id, query the Redis database and free access.
William can put examples of code to solve the problem?
– Sergio
It is that the solution is not very small. There are some articles on how to save sessions in the PHP database, for example, which are a little long.
– Guilherme Portela