Jump to content

setting cookie


SUNIL16

Recommended Posts

Hi Friends,

 

I set cookie like below after the user login.

<?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);
include("welcome.php");
exit();
} 
else {
include("re_login.html");
exit();
}

 

But now the problem is the user can login but the cookie is set only after 2logins means he has to login again to post any thing. what is the problem with cookie...

Link to comment
https://forums.phpfreaks.com/topic/142590-setting-cookie/
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.