Hi,
For some reason, my code is attaching
to one of the cookies it's setting and not the other, which makes it somewhat easier to diagnose, but I can't do it, partially because I've been working with the code for 2 hours and it feels fine. Here's a quick explanation of the code below: $serversecuritycode is fetched from the user , $safeusername is the username submitted through a form and taken through mysql_real_escape_string. When it's setting the cookies, the $serversecuritycode (the securitycode cookie) gets the %0D%0A attached. The username one stays fine.
Here's the relevant code:
if (!isset($_POST["username"]) || !isset($_POST["password"]))
{
$displayform=1;
}
else
{
$safeusername=mysql_real_escape_string($_POST["username"]);
$safepassword=mysql_real_escape_string($_POST["password"]);
$serverpassword = mysql_query("SELECT `password` FROM `users` WHERE username = \"{$safeusername}\"");
$serversecuritycode = mysql_query("SELECT `securitycode` FROM `users` WHERE username = \"{$safeusername}\"");
if(mysql_num_rows($serversecuritycode)==0)
{
$displayincorrect=1;
}
else
{
if($safepassword==mysql_result($serverpassword,0,0))
{
// *** COOKIE AREA ***
$serversecuritycode = mysql_result($serversecuritycode,0,0);
setcookie("securitycode", $serversecuritycode, time()+63072000); /* Expires in 2 years */
setcookie("username", $safeusername, time()+63072000);
$success=1;
}
else
{
$displayincorrect=1;
}
}
}
Another weird thing: At the part where I put the ***COOKIE AREA***, I used to have the following for debug purposes:
echo ("$serversecuritycode");
For some reason, it never spat out a header error, which it has done before. Can anyone explain why?