Jump to content

Cookies not being set


nelspruitdesign

Recommended Posts

Everything works except the cookies are not being set, any ideas?, Error reporting is that headers have already been set, I don't see it

 

 

$uname = $_REQUEST["uname"];

$upass = $_REQUEST["upass"];

$ref = $_REQUEST["ref"];

 

$uname = str_replace("&", "'", $uname);

$uname = str_replace("'", """, $uname);

$uname = str_replace("\"", "\", $uname);

$uname = str_replace("+", "+", $uname);

 

$upass = str_replace("&", "'", $upass);

$upass = str_replace("'", """, $upass);

$upass = str_replace("\"", "\", $upass);

$upass = str_replace("+", "+", $upass);

 

If ($uname != NULL) {

$username="xxxx";

$password="xxxx";

$database="xxxx";

$server="xxxx";

 

mysql_connect($server,$username,$password);

@mysql_select_db($database) or die("Something is broken and needs fixing. Please contact us <a href=\"http://xxxx/contact..../contact.php\"> and report this</a>");

 

$sqlq="SELECT * FROM xxxx WHERE xxxx = '".$uname."' AND xxxx = '".$upass."' LIMIT 0,1";

$objRS = mysql_query($sqlq);

while($row = mysql_fetch_array($objRS, MYSQL_ASSOC)){

$uname = $row["xxxx"];

$suid = $row["xxxx"];

$sname = $row["xxxx"];

$upass = $row["xxxxx"];

}

$rows = mysql_num_rows($objRS);

if (empty($rows)) {

$title = "Log In";

include ("../navigation/header.php");

 

?>

<div id="contenti">

<div id="contwrap">

<div id="iwrap1">

 

<? ?>

<h2> Log In Failed</h2>

The username or password is incorrect, please try again

<?

} else {

setcookie("suid",$suid, time()+14400);

setcookie("aka",$sname, time()+14400);

setcookie("logged","yes", time()+14400);

 

$title = "Log In";

include ("../navigation/header.php");

?>

<div id="contenti">

<div id="contwrap">

<div id="iwrap1">

 

<?

echo "You have succesfully logged in. <a href=\"".$ref."\">Click here to return to the previous page</a>";

}

 

} else {

header( 'Location: ../index.php' ) ;

}

Edited by nelspruitdesign
Link to comment
Share on other sites

The headers are sent here:

?>
  <div id="contenti">
<div id="contwrap">

 

The only reason why it would work if you put it into another folder, is if said folder contains a .htaccess that enabled output buffering. Which is a bad hack which only removes the symptom, not the actual problem.

The FAQ, which is linked at the top of this section, contains a link to a thread that details how to fix header errors. I recommend reading it, and adhering to its advice.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.