save-state.php 396 B

1234567891011121314151617
  1. <?
  2. session_start();
  3. if(!isset($_SESSION['state'])){
  4. $_SESSION['state'] = array(
  5. 'sessionId'=>session_id()
  6. );
  7. }
  8. foreach($_COOKIE as $name=>$value){
  9. // look for state cookies
  10. if(strpos($name, 'ys-') === 0){
  11. // store in session
  12. $_SESSION['state'][substr($name, 3)] = $value;
  13. // remove cookie
  14. setCookie($name, '', time()-10000, '/');
  15. }
  16. }
  17. ?>