PHP手册上的例子: $_session_data是一个多维数组 <?php // $session_data contains a multi-dimensional array with session // information for the current user. We use serialize() to store // it in a database at the end of the request.$conn = odbc_connect("webdb", "php", "chicken"); $stmt = odbc_prepare($conn, "UPDATE sessions SET data = ? WHERE id = ?"); $sqldata = array (serialize($session_data), $_SERVER['PHP_AUTH_USER']); if (!odbc_execute($stmt, $sqldata)) { $stmt = odbc_prepare($conn, "INSERT INTO sessions (id, data) VALUES(?, ?)"); if (!odbc_execute($stmt, $sqldata)) { /* Something went wrong.. */ } } ?>
2.你可以把数据做成json(json_encode)格式的或者你把而为数组序列化一下(serialize)
$url ="xxx.php?arg=".json_encode($arr);header("location:".$url);
$_session_data是一个多维数组
<?php
// $session_data contains a multi-dimensional array with session
// information for the current user. We use serialize() to store
// it in a database at the end of the request.$conn = odbc_connect("webdb", "php", "chicken");
$stmt = odbc_prepare($conn,
"UPDATE sessions SET data = ? WHERE id = ?");
$sqldata = array (serialize($session_data), $_SERVER['PHP_AUTH_USER']);
if (!odbc_execute($stmt, $sqldata)) {
$stmt = odbc_prepare($conn,
"INSERT INTO sessions (id, data) VALUES(?, ?)");
if (!odbc_execute($stmt, $sqldata)) {
/* Something went wrong.. */
}
}
?>