在javascript中解析Symfony2会话数据

时间:2013-10-29 13:37:27

标签: javascript session symfony

我在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()来userialize并获取另一个序列化数据(“_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对象中转换此序列化字符串?

0 个答案:

没有答案