1

socket.io + Symfony2 でチャットを書いています。私の Symfony は、セッションを mysql データベースに保存するように構成されています。socket.io サーバー アプリケーションでは、このセッションを mysql から取得しますが、非常に大きな問題は、このセッションを解析することです。

session_data フィールドには次の文字列が含まれます (base64_decoded 後):

_sf2_attributes|a:1:{s:22:"_security_primary_auth";s:715:"C:74:"Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken":627:{a:3:{i:0;N;i:1;s:4:"main";i:2;s:587:"a:4:{i:0;C:30:"App\UserBundle\Entity\User":245:{a:9:{i:0;s:88:"mmTTBVj/wlB0EFvL1nkMmcW/DXd9jREQWAEWd5WJFNVnX2bJrpOTL3wZDO1+T5tYQsiXT8nyMYKbVSEZDq+QDQ==";i:1;s:31:"9mpqmv3075kw8k80wgoc8wokcgkw8sc";i:2;s:16:"info@app.com";i:3;s:16:"info@app.com";i:4;b:0;i:5;b:0;i:6;b:0;i:7;b:1;i:8;i:2;}}i:1;b:1;i:2;a:2:{i:0;O:41:"Symfony\Component\Security\Core\Role\Role":1:{s:47:"^@Symfony\Component\Security\Core\Role\Role^@role";s:12:"ROLE_COMPANY";}i:1;O:41:"Symfony\Component\Security\Core\Role\Role":1:{s:47:"^@Symfony\Component\Security\Core\Role\Role^@role";s:9:"ROLE_USER";}}i:3;a:0:{}}";}}";}_sf2_flashes|a:0:{}_sf2_meta|a:3:{s:1:"u";i:1383052184;s:1:"c";i:1383052144;s:1:"l";s:6:"360000";}

js-php-unserialize - unserializeSession() を使用して、別のシリアル化されたデータ (「_sf2_attributes」キー) をユーザー化して取得します。

a:1:{s:22:"_security_primary_auth";s:715:"C:74:"Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken":627:{a:3:{i:0;N;i:1;s:4:"main";i:2;s:587:"a:4:{i:0;C:30:"App\UserBundle\Entity\User":245:{a:9:{i:0;s:88:"mmTTBVj/wlB0EFvL1DnMmcW/fgd9jREQWAEWd5WJFNVnX2bJrpOTL3wZDO1+T5tYQsiXT8nyMYKbVSEZDq+QDQ==";i:1;s:31:"9mpqmv3075kw8k804soc8fgkcgkw8sc";i:2;s:16:"info@app.com";i:3;s:16:"info@app.com";i:4;b:0;i:5;b:0;i:6;b:0;i:7;b:1;i:8;i:2;}}i:1;b:1;i:2;a:2:{i:0;O:41:"Symfony\Component\Security\Core\Role\Role":1:{s:47:"^@Symfony\Component\Security\Core\Role\Role^@role";s:12:"ROLE_COMPANY";}i:1;O:41:"Symfony\Component\Security\Core\Role\Role":1:{s:47:"^@Symfony\Component\Security\Core\Role\Role^@role";s:9:"ROLE_USER";}}i:3;a:0:{}}";}}";}

私の問題があります-シリアル化を解除できません。より多くのライブラリを試します。問題は「C:」キーにあると思います。このシリアル化された文字列を javascript オブジェクトに変換するにはどうすればよいですか?

4

0 に答える 0