session_encode
session_encode — 將當前會話數據編碼為一個字符串
說明
string session_encode ( void )
session_encode()返回一個字符串,該字符串包含有被編碼的當前會話數據。
代碼如下 復制代碼
<?
//boolean session_encode()
session_register ( 'bgcolor' );
session_register ( 'fontcolor' );
$id = session_id ( $usr_id );
$bgcolor = "white";
$fontcolor = "blue";
$usr_data = session_encode ();
print $usr_data;
?>
session_decode
代碼如下 復制代碼
<?
session_start();
$_SESSION = array();
session_decode( "products|a:2:{i:0;s:8:"Hal 2000";i:1;s:6:"Tardis";}" );
foreach ( $_SESSION['products'] as $p ) {
print "$p<br/>n";
}
?>