Reputation: 1304
so I have 2 pages: Chat page which runs on Node.js and Socket.io (WebSockets). And main page where user logins etc... I want to make it so when user logins on main page -> it validates details -> then stores user ID in session and goes into chat where he's identified by his userID.
Oh yeah and user accounts are stored on MySQL.
Upvotes: 0
Views: 328
Reputation: 106726
You can parse PHP (file-based) sessions from node with a module like groan. However, a better solution is probably to use a better session store such as redis. An example of sharing sessions between node and PHP using redis can be found here.
Upvotes: 1
Reputation: 1844
Okay. Cookies mechanism was created to communicate with different environments. Let's use it..
PHP:
Validate user data and save it into DB and then save id
to cookies.
NodeJS:
Read that id
from cookies and get data from DB (MySQL provider for nodejs)
Upvotes: 0