MR alaa

MR alaa

  • 1.1k
  • 631
  • 21.4k

setcookie doesnt appear in explorer

Dec 20 2015 6:28 AM
hi every body i have write this simple cookie in two project in t he first one it works fine i use it in another project but when i click F12 i see nothing in the cookie i make debug i see it take values but it doesnt appear in explorer or churom .....
this is my code can i find help for my problem
 
function checkLogin($u, $p)
{
global $seed; 
if (!valid_username($u) || !valid_password($p) || !user_exists($u))
{
return false; 
}
$query = sprintf("
SELECT `U_id ' ,'Md5_id`, `M_Username`, `M_password`,`user_level` FROM `members`
WHERE
M_Username = '%s' AND M_password = '%s'
AND M_status = 'on'
LIMIT 1;", mysql_real_escape_string($u), mysql_real_escape_string(sha1($p . $seed)));
$result = mysql_query($query);
if (mysql_num_rows($result) != 1)
{
return false;
} else
{
$row = mysql_fetch_array($result);
session_start();
session_regenerate_id (true); 
$user_md5id=$row['Md5_id'];
$_SESSION['loginid']= $row['U_id'];
$_SESSION['username'] = $u;
$_SESSION['ckey'] = GenKey();
$_SESSION['user_level'] = $row['user_level'];
$_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
$stamp = time();
$ckey = GenKey();
$on_offline="on";
$serial = trim(str_replace("(","",str_replace(")","",GetVolumeLabel("c"))));
$db = new mysqli('localhost', 'root', '', 'blabla');
$query=sprintf("UPDATE `login_case` SET `ckey`='$ckey',`ctime`='$stamp',`on_offline`='$on_offline',`Logindate`='$stamp',`hard_serial`='$serial' WHERE `U_id`='$user_md5id'");
mysqli_query($db,$query);
define("COOKIE_TIME_OUT", 10); //specify cookie timeout in days (default is 10 days)
define('SALT_LENGTH', 9); // salt for password
if(isset($_POST['remember'])){
setcookie("loginid", $_SESSION['loginid'], time()+60*60*24*COOKIE_TIME_OUT, "/");
setcookie("user_key", sha1($ckey), time()+60*60*24*COOKIE_TIME_OUT, "/");
setcookie("username",$_SESSION['username'], time()+60*60*24*COOKIE_TIME_OUT, "/");
}
return true;
}
return false;
}
 

Answers (1)