0
我想超時會話,如果用戶不使用的網站。我已經看到了被他人使用該功能在互聯網上:會話超時PHP問題
ini_set('session.gc_maxlifetime', 10);
我我把這個函數放在我的代碼中,但沒有任何反應。不超時,我沒有錯誤。我究竟做錯了什麼?
下面是我把它放在代碼:
<?php
ini_set('session.gc_maxlifetime', 10);
session_start();
ob_start();
include("dbinfo.inc.php");
[email protected]_connect($host,$username,$password);
[email protected]_select_db($database) or die("Unable to select database");
// username and password sent from form
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
// To protect MySQL injection
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM login WHERE username='$myusername' and password=sha1('$mypassword')";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
// Register $myusername, $mypassword and redirect to file "home.html" if successful
$_SESSION['username'] = $myusername;
$_SESSION['password'] = $mypassword;
header("Location:home.php");
}
?>
請檢查http://stackoverflow.com/questions/3428153/php-ini-setsession-gc-maxlifetime-5-why - 它-犯規,最終的會我見過這個職位已經並試圖實現我的代碼解決方案 – mesutozer
但有沒有運氣:/ – Lloyd
其實,這是沒有辦法了。它解釋了爲什麼在腳本中設置'session.gc_maxlifetime'不起作用。 – mesutozer