title: User relationships are corrupting my sessions in Symfony2
body: <p>My users have a number of relationships setup in Doctrine but one in particular  seems to be causing me a lot of problems, each user can have a number of memberships and each membership has a membership type.</p>
  
  <p>For some reason however when I load those memberships it seems to be nuking my session, I login and get presented with a "Your Account" page as I should do but if I refresh the page I get sent back to the login screen. My sessions are stored in the database so I've been checking them to see what happens and this is what I'm seeing:</p>
  
  <ol>
  <li>Session starts off empty</li>
  <li>I login but make sure I get redirected to a page that doesn't load memberships</li>
  <li>Session now contains user object and all info about relationships</li>
  <li>I visit "Your Account" which loads memberships, they get displayed correctly.</li>
  <li>Session has been nuked and is now as it was in step 1</li>
  <li>I refresh the page and get sent back to the login page</li>
  </ol>
  
  <p>I've defined my own user provider and I noticed if I set the membership type on each membership to null in refreshUser it starts working so I'm guessing the session is having trouble with that relationship.</p>
  
  <p>I'm really struggling to find a solution to this so any help would be really appreciated.</p>
  
  <p>EDIT: Been doing some more experimenting and found if I switch to file sessions everything starts working so it must be related to storing sessions in the database. I made the switch using the guide in the Symfony Cookbook. For reference here are the relevant bits from my config.yml:</p>
  
  <pre><code>framework:
      session: 
          default_locale: %locale%
          auto_start:     true
          storage_id:   session.storage.pdo
  
   parameters:
      pdo.db_options:
          db_table:       session
          db_id_col:      session_id
          db_data_col:    session_value
          db_time_col:    session_time
  
   session.storage.pdo:
      class:     Symfony\Component\HttpFoundation\SessionStorage\PdoSessionStorage
      arguments: [@pdo, %session.storage.options%, %pdo.db_options%]
   pdo:
      class: PDO
      arguments:
          dsn:      "mysql:dbname=%database_name%;host=%database_host%"
          user:     %database_user%
          password: %database_password%
  </code></pre>
  
  <p>Everything else about them seems fine so maybe it's a bug in PdoSessionStorage</p>