title: How to add a custom field to the session table
body: <p>I'm currently using <code>Symfony 2.1.8</code> and the built-in <code>PdoSessionHandler</code>.</p>
  
  <p>I want to add a <code>user_id</code> field in the session table to identify to which (logged-in) user the session belongs. The idea is that I can force the user to log back in destroying his session. In my case it will happen if the privileges of the user are updated.</p>
  
  <p>I had a look to the build-in <code>PdoSessionHandler</code> that you can't extends because of those silly private variables.</p>
  
  <p>So I've tried created a new one (copy/paste) and add my column <code>user_id</code>.
  Now this column can be null if the user is not logged in (anonymous users).</p>
  
  <p>So I want to write this <code>user_id</code> in the write method of the handler. The user is already stored in the <code>$data</code> so I was thinking that I could check if this user exists, grab its <code>id</code> and add it in the insert / update query.</p>
  
  <p>The problem is that <code>$data</code> is encoded - I guess by session_encode() - so I'm not sure anymore this is the best place ever to handle my new field, but at the same time I can't see anywhere else I could do it as I need to update this MySQL query to insert the value of the new field.</p>
  
  <p>So my question is: <strong>where is the best place to handle this additional field? And how to set this user_id value?</strong></p>
  
  <p>On another note, somehing really annoying is that <code>Symfony</code> is creating a new cookie each time I'm logging in or out. So the database ends up with lots of records for nothing (it's always the same user). Why <code>Symfony</code> is not using the same cookie value all the time?</p>