把session存入数据库后,它是一个经过serialize过的数据,如果想不通过symfony读取出来,需要unserialize。
通过这个函数:

  1. function unserialize_session_data($serialized_string)
  2. {
  3.     $variables = array();
  4.     $a = preg_split( "/(\w+)\|/", $serialized_string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
  5.  
  6.     for( $i = 0; $i < count( $a ); $i = $i+1 ) {
  7.         if ($a[$i] == 'attributes'){
  8.             $variables[$a[$i]] = unserialize( $a[$i+1] );
  9.             break;
  10.         }
  11.     }
  12.     return $variables;
  13. }

Continue reading »

This issue will be fixed with symfony 1.1.1:
http://trac.symfony-project.com/ticket/3857 (see comments)

© 2011 刘敏的Blog Suffusion theme by Sayontan Sinha