Php 会话超时问题

Php 会话超时问题,php,html,sql,session-timeout,Php,Html,Sql,Session Timeout,如果用户不使用该站点,我将尝试超时会话。。我在互联网上看到其他人正在使用此功能: ini_set('session.gc_maxlifetime', 10); 我在代码中加入了这个函数,但什么也没发生。没有超时,我没有错误。我做错了什么 以下是我输入的代码: <?php ini_set('session.gc_maxlifetime', 10); session_start(); ob_start(); include("dbinfo.inc.php"); $comm=@mysql

如果用户不使用该站点,我将尝试超时会话。。我在互联网上看到其他人正在使用此功能:

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");
}
?>


请检查我已经看到了那篇文章,并尝试在我的代码中实现解决方案,但没有运气:/事实上,这不是一个解决方案。它解释了为什么在脚本中设置
session.gc\u maxlifest
不起作用。。我不确定还可以使用什么来超时会话:/n您仍然可以使用session.gc\u maxlifetime。但您需要在php.ini或.htaccess文件中设置它的值。请注意,即使会话处于活动状态,也会导致会话过期。如果需要超时空闲会话,则情况不同。我有类似于my home.php文件中的代码:
    <?php 
    session_start();

    include("dbinfo.inc.php"); 

    if(empty($_SESSION['username'] )){

    echo "Please login.Time out";


    }