nelspruitdesign Posted January 27, 2013 Share Posted January 27, 2013 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' ) ; } Link to comment https://forums.phpfreaks.com/topic/273689-cookies-not-being-set/ Share on other sites More sharing options...
nelspruitdesign Posted January 27, 2013 Author Share Posted January 27, 2013 Jebus I hate my ISP, I put it in a different directory and now it works. Exactly the same code in one directory does squat and in another it gives me the results I want. Link to comment https://forums.phpfreaks.com/topic/273689-cookies-not-being-set/#findComment-1408500 Share on other sites More sharing options...
Christian F. Posted January 27, 2013 Share Posted January 27, 2013 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 https://forums.phpfreaks.com/topic/273689-cookies-not-being-set/#findComment-1408511 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.