Jump to content

Cookie is not setting in first login


SUNIL16

Recommended Posts

Hi Friends,

 

I am using the below script for login, But the problem is cookie is setting only if they login twice.

 

this is my code

 

<?php
require "config.php";  

$username=$_REQUEST["uname"];
$password=md5($_REQUEST["password"]);



$sql="SELECT usersid,username,password FROM users WHERE username='$username' and password='$password'";
$result=mysql_query($sql);

$rows=mysql_fetch_array($result);
$memberid=$rows['usersid'];
$count=mysql_num_rows($result);

if($count == 1) {
setcookie("myusername", "$username",time()+3600);
header("Location:welcome.php");
exit();
} 
else {
include("re_login.html");
exit();
}

?>

 

Please help...

 

if they login second time it is setting...

Link to comment
https://forums.phpfreaks.com/topic/145518-cookie-is-not-setting-in-first-login/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.