Hi,
We successfully did this before the new event broadcasting stuff was added. You are on the right track. You need to decrypt their cookie and then use it to retrieve the user's session, this is quite easy if you also use redis for sessions.
We have this code, which I think I got from a blog post somewhere, unfortuanatrly i can't find it now!
/**
* Helper function to return ASCII code of character
* @param [string] string
* @return [ascii code]
*/
function ord( string ) {
return string.charCodeAt( 0 );
}
/**
* This function retrieves the laravel session stored in redis
* from a cookie
* @param [cookie] cookie
* @return session
*/
function getSessionIdFromLaravelCookie( cookie ) {
var cookie = JSON.parse( new Buffer( cookie, 'base64' ) );
var iv = new Buffer( cookie.iv, 'base64' );
var value = new Buffer( cookie.value, 'base64' );
var key = 'dd4u1wm2rVi82s6eOI8sTRzaWomob58x'; // laravel app key
var rijCbc = new MCrypt( 'rijndael-128', 'cbc' );
rijCbc.open( key, iv ); // it's very important to pass iv argument!
var decrypted = rijCbc.decrypt( value ).toString();
var len = decrypted.length - 1;
var pad = ord( decrypted.charAt( len ) );
var sessionId = PHPUnserialize.unserialize( decrypted.substr( 0, decrypted.length - pad ) );
return sessionId;
}
After you have done this you should be able to get their session using from the redis db and then it should be fairly straight forward from there.