如果用户不使用该网站,我正在尝试使会话超时。我在互联网上看到其他人正在使用此功能:
ini_set('session.gc_maxlifetime', 10);
我已经把这个函数放在我的代码中,但没有任何反应。不超时,我没有错误。我做错了什么?
这是我输入的代码:
<?php
ini_set('session.gc_maxlifetime', 10);
session_start();
ob_start();
include("dbinfo.inc.php");
$comm=@mysql_connect($host,$username,$password);
$rs=@mysql_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");
}
?>
<?php
session_start();
include("dbinfo.inc.php");
if(empty($_SESSION['username'] )){
echo "Please login.Time out";
}