title: PHP: setting session variables through variable variables
body: <p>I would like to set a session variable with something akin to:</p>
  
  <pre><code>$key = '_SESSION[element]';
  $$key = 'value';
  </code></pre>
  
  <p>This does indeed set <code>$_SESSION['element']</code> equal to <code>value</code>, but it also seems to clear the rest of my <code>$_SESSION</code> variable, resulting in the <code>$_SESSION</code> array only containing the new key/value pair.</p>
  
  <p>How can I write into the session using variable variables without nuking it?</p>
  
  <p><strong>Edit:</strong> if this can't be done, so be it, we'll probably have to restructure and do things the "right" way. I just wanted to know if there was an easy fix</p>