dear friends...
Can we set time for the session to expire..?
If anybody know...plz send me the code...
here is link where you can find lots of examples.
php.net
but i recommend to use cookies and set expiration time
read this
or if you need high security and realibility, use your own 'expiration time', i.e. create cookie with value and its expirity date and compare it with datebase.
something like that
login.php ->
-
<?php
-
-
$uID = uniqid("");
-
$IPaddress = $_SERVER["REMOTE_ADDR"];
-
mysql_query("UPDATE user SET uID='$uID',IPaddress='$IPaddress',date='".date("U")."' WHERE username='$username'");
-
-
-
setcookie("username",$username);
-
setcookie("uID",$uID);
-
-
-
-
?>
-
check authentication ->
-
<?php
-
-
function issesauth()
-
{
-
-
$usi = filter($_COOKIE['username']);
-
$ida = filter($_COOKIE['uID']);
-
-
$vaxkakoi = MYSQL_QUERY("SELECT * FROM user WHERE username='$usi' AND uID='$ida' AND activ='Y'");
-
$chachacha = mysql_fetch_array($vaxkakoi);
-
if(!$chachacha){
-
setcookie("username");
-
setcookie("uID");
-
return false;
-
}else{
-
$IPserver = $chachacha['IPaddress'];
-
$diff = $chachacha['date']+constant("timeLim")-date("U");
-
$IPrecent = $_SERVER["REMOTE_ADDR"];
-
-
-
if(($IPserver != $IPrecent)||($diff<0)){
-
setcookie("username");
-
setcookie("uID");
-
return false;
-
}else{
-
$datu = date("U");
-
mysql_query("UPDATE user SET date='$datu' WHERE username='$usi'");
-
return true;
-
}
-
}
-
}else{
-
setcookie("username");
-
setcookie("uID");
-
return false;
-
-
}
-
-
-
-
?>
-
you can use this function to check authorisation of user, and set his login validity period manualy, and it works better... i
of course u need databe where you can store users password, uID (userid) and date (time of login). good luck.