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