NodeJS with PHP application and user session NodeJS with PHP application and user session symfony symfony

NodeJS with PHP application and user session


Can be done using a common data store like redis to store user sessions

Check this link for reference

http://simplapi.wordpress.com/2012/04/13/php-and-node-js-session-share-redi/

Also check

http://www.slideshare.net/leeboynton/integrating-nodejs-with-php-march-2013-1

Which gives you an overview of how sessions can be shared using a common in-memory data store and some sample memcached code.

WebSockets

If you are using nodejs just for the WebSockets part, I'd suggest not to because then you'd have to replicate your user authentication logic in nodejs as well

You can instead do WebSockets in PHP using some library like http://socketo.me/

As far as storing the messages in MySQL goes

Your first approach of making an AJAX call to store the message in database, waiting for the response and then emitting a SocketIO event would lead to a sluggish chat experience.I'd suggest you store messages to MySQL through NodeJS (asynchronously)

On a side-note check https://github.com/kyle-dorman/ChitChat.js for adding real-time chat functionality to your website.