Wordpress authentication in node.js


Staff member
What is the best way to allow a user to use a node.js app using their user account from a Wordpress page?

I have tried storing session information in Redis, but I am not very familiar with PHP and have run into a dead end where the session isn't being stored. I have used this <a href="http://simplapi.wordpress.com/2012/04/13/php-and-node-js-session-share-redi/" rel="noreferrer">guide</a>.

I have also tried using <a href="https://github.com/jhurliman/node-phpass" rel="noreferrer">node-phpass</a> but it is not very well documented. I have successfully connected to the Wordpress database, but the password hashes I generate with node-phpass do not match the hashes in the wp_users table.

This is what I'm using to test node-phpass:

var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'wordpress',
  password : 'jPWrwvGbYXMADd8F',
  database : 'wordpress',

connection.query('SELECT * FROM wp_users', function(err, rows) {
    if (err) { 
        console.log("Database error: " + err);
    } else {
         for (var i = 0; i &lt; rows.length; i++){
            console.log("Rows[" + i + "] : " + rows[i].user_login + " " + passwordHash.checkPassword('secret',rows[i].user_pass));

Aside from sharing the session, are there any other better ways to do this? OAuth?