我已經閱讀了很多關於php安全性的最佳實踐,所以我努力在我的xampp服務器上使用這些最佳實踐。我的php會話在登錄後不斷丟失
我有一個包含所有我的安全性,ddos,會話管理,並有一個名爲sec_session_start的函數。代碼如下,但當我嘗試登錄,然後重定向回到我的主頁時,所有會話數據都消失了。在我的登錄進程頁面上,在我進行重定向之前,它擁有所有正確的會話數據。
每個標題後,我正在做「退出」。我也試過寫session_write_close();
但這並不能解決我的問題。
以下是功能碼。
function sec_session_start() {
$session_name = 'AnyName'; // Set a custom session name
$secure = false; // Set to true if using https.
$httponly = true; // This stops javascript being able to access the session id.
ini_set('session.use_only_cookies', 1); // Forces sessions to only use cookies.
$cookieParams = session_get_cookie_params(); // Gets current cookies params.
session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly);
session_name($session_name); // Sets the session name to the one set above.
session_start(); // Start the php session
session_regenerate_id(true); // regenerated the session, delete the old one.
}
這個函數在每一頁都被調用。
有什麼建議嗎?
這是包含每個頁面調用get的代碼。 http://pastebin.com/e5r4Uvvu – crosenblum