Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I write chat on socket.io + Symfony2. My Symfony is configured to store session in mysql database. In socket.io server application I get this session from mysql, but very big problem is parse this session.

session_data field contain this string (after 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:"[email protected]";i:3;s:16:"[email protected]";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";}

I use the js-php-unserialize - unserializeSession() to userialize and obtain another serialized data ("_sf2_attributes" key)

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:"[email protected]";i:3;s:16:"[email protected]";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:{}}";}}";}

and there is my problem - I can't unserialize, I try more libs. I think problem is in the "C:" key, how transform this serialized string in javascript object?

share|improve this question
    
Why do you send serialized data to JS in the first place? –  CBroe Oct 29 '13 at 13:44
    
I get this session data from database. –  Igor Ladela Oct 29 '13 at 13:45
    
Sounds like you are reading that data from the database directly, circumventing Symphony at this point. –  CBroe Oct 29 '13 at 13:47
    
yes, I need parse this in javascript. –  Igor Ladela Oct 29 '13 at 13:51
    
Why? Parse it server-side, and send it to JavaScript in a format that is easily understandable to JS, such as JSON … –  CBroe Oct 29 '13 at 13:59
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.