title: NodeJS with PHP application and user session
body: <p>I have a PHP application (with Symfony2) and I need to let my users talk, and other tings, in real time (with socket.IO).
  Let's focus on the chat mechanism : A logged user can talk with an other logged user (logged with FOSUserBundle in Symfony). When the user sent a message, it must be saved in MySQL and sent in real time to the other user. So the message is linked to two users (a sender and a receiver) in my MySQL database.</p>
  
  <p>So I have two possibilities :</p>
  
  <ul>
  <li>I use PHP to store messages :
  <ul>
  <li>I have an event on the click "submit" and call a PHP url with AJAX</li>
  <li>If my PHP return "OK" (so he correctly added the message in database), I emit a Socket.IO event -> let doctrine deal with datas and symfony with my user</li>
  <li>On NodeJS side, I have a listener on this event and I sent the message through Socket.IO with an other event</li>
  </ul></li>
  <li>I use only NodeJS :
  <ul>
  <li>How can I log my user on PHP and NodeJS side ?</li>
  <li>I need to use a different database for datas in real time ?</li>
  <li>How can I share my users between NodeJS and PHP ?</li>
  </ul></li>
  </ul>
  
  <p>I don't know what is the cleanest solution, if someone can help me.
  Thanks !</p>