How to save php session in MongoDB and retrieve data in NodeJS

1

I'm running a server in php and another in nodejs trying to get a simple authentication since every session runs on php and nodejs it simply processes some events however, and authentication is needed as I can with MongoDB (drive php)?

I tried with memcache (php and node) but did not succeed since memcache dll for php7 is still in dev status (development).

    
asked by anonymous 30.05.2016 / 15:21

1 answer

0

Instead of a session, you can use the JWT pattern of tokens, you will find ready material in several languages.

For example, at login you can generate the token, and check it on another machine, without accessing the database. This is perfect for scalability because multiple servers can validate the token without talking to each other. It is only necessary that both use the same key.

  • Documentation, playground and examples: link
  • Implementation in NodeJS: link
  • PHP implementation: link

The JWT token can contain information such as the user ID, and also has an expiration date, which will be respected at the time of validation.

    
30.05.2016 / 22:30