session_register可以存儲多個值嗎?因爲在我的視圖產品頁面中,我可能需要將session_register中的值輸入到數據庫中。session_register可以存儲多個值嗎?
if(!isset($_SESSION['login_school']))
{
header("location: ../enter-icas/");
}
這是登錄頁面。
$_SESSION['login_school'] = $myschoolcode;
header("location: ../view-products/");
這是用戶登錄後的產品頁面。
目前上面的代碼存儲學校代碼,我怎樣才能讓會話存儲我的學校名稱呢?
$myschoolcode = ($_POST['schoolcode']);
$mypassword = ($_POST['password']);
$sql = "SELECT school_id FROM schools_info WHERE SchoolCode = '$myschoolcode' and Password
= '$mypassword'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$active = $row['active'];
$count = mysql_num_rows($result);
// If result matched $myschoolcode and $mypassword, table row must be 1 row
if($count == 1) {
session_register("myschoolcode");
$_SESSION['login_school'] = $myschoolcode;
header("location: ../view-products/");
}
使用$ _SESSION ['school_name'] =「學校名稱」; – 2013-04-21 11:14:14
閱讀文檔 - http://www.php.net/manual/en/function.session-register.php - 答案是「是」;但不要讓你的代碼依賴於在下一個版本的PHP中將被棄用的函數 – 2013-04-21 11:17:39