inz.fi

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

node-js-and-wordpress-sessions.md (745B)


      1 # node.js and wordpress sessions
      2 
      3 For a leetle project, I needed a way to validate a wordpress session from node.js. Wordpress uses a somewhat complicated session system, with HMACs and using part of password salt, and was unable to find a ready puzzle piece for the purpose. So I wrote my own.
      4 
      5 The result is [a javascript module](https://inz.fi/p/wpsess.javascript). Sample usage:
      6 
      7 	var wps = require('wpsess');
      8 	var vdtor = new wps.Validator('/path/to/my/wp-config.php');
      9 	vdtor.validate('value_of_my_logged_in_cookie', function (err, username) {
     10 	    if (err)
     11 	        console.log('Authentication failed: ' + err);
     12 	    else
     13 	        console.log('Logged in user: ' + username);
     14 	});
     15 
     16 It is way from perfect, but it works well enough for me.