Domanda

I am attempting to access session variables set via php stored in memcached from node.

I would really like the format of the stored session data to be in JSON.

I found msgpack and that looked like it might do the job, however, a console.log of the session data within node reveals that items are seperated by little ? marks:

���user_id�1�company_id�1�fname�name�lname�lname�lactivity�S.7��login_st.... and so on

My php file

//serialize in a nice JSON FORMAT

ini_set('session.serialize_handler', 'msgpack');

//use MEMCACHED to save sessions

ini_set('session.save_handler', 'memcached');

//the port memcached is running on

ini_set('session.save_path', 'localhost:11211');

I am trying to access the php sessions from node, where I use JSON.parse however it always gets an invalid character error.

If anyone has any ideas I would be most grateful!

Grant

È stato utile?

Soluzione

Messagepack isn't JSON, so using JSON.parse on Messagepack's data won't work.

You should use this Node module which allows parsing Messagepack's objects in Node.

Example usage :

var msgpack = require('msgpack'); // import the node-msgpack module

var unpacked = msgpack.unpack(packed); // unpack the "packed" variable
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top