如果用户没有使用该网站,我会尝试将会话超时..我已经在互联网上看到此功能被其他人使用:
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");
}
?>
答案 0 :(得分:0)
<?php
session_start();
include("dbinfo.inc.php");
if(empty($_SESSION['username'] )){
echo "Please login.Time out";
}