guymclaren Posted February 3, 2012 Share Posted February 3, 2012 The code below is the only part of my script failing and I have no clue why. I even tried setting the TestCookie for 352 days. What boggles my mind is that this code used to work and is now failing. Has something changed? $value = "wtf"; setcookie("TestCookie",$value, time()+3600*24); setcookie("user", $name1, time()+14400); setcookie("userid", $uid1, time()+14400); setcookie("coid", $coid1, time()+14400); setcookie("login", "yes", time()+14400); setcookie("status", $status1, time()+14400); Quote Link to comment https://forums.phpfreaks.com/topic/256308-cookies-not-being-set/ Share on other sites More sharing options...
guymclaren Posted February 3, 2012 Author Share Posted February 3, 2012 Here is the full code in context <?php include ("../navigation/header.php"); $ident = "0"; $basket = $_REQUEST["id"]; $name = $_REQUEST["uname"]; $pass1 = $_REQUEST["pass1"]; include ("../navigation/constants.php"); ?> <div id="contenti"> <div id="iwrap1"> <div class="post-title"> <h2> Catalogue - Log In</h2> </div> <div id="post-entry"> <? //Check if form has been filled in If ($name != NULL){ If ($pass != NULL) { //check database $sqlq="SELECT * FROM Clcontacts INNER JOIN Clients ON Clcontacts.Company=Clients.id WHERE Clcontacts.email = '".$name."' AND Clcontacts.password = '".$pass1."'"; $objRS = mysql_query($sqlq); $rows = mysql_num_rows($objRS); if ($rows == 0) { echo "<h2>Log in failed</h2>The username or password is incorrect, please try again"; ?> <h2>Log In</h2> <form action="login.php" method="GET"> <table> <tr><td>user name: (email address)</td><td><input type="text" name="uname" /></td></tr> <tr><td>Password:</td><td><input type="password" name="pass1" /></td></tr> <tr><td></td><td><input type="submit" value="Submit" /></td></tr></table> </form> <? } else { $email = mysql_result($objRS, 0,"Clcontacts.email"); $name1 = mysql_result($objRS, 0,"Clcontacts.name"); $uid1 = mysql_result($objRS, 0,"Clcontacts.id"); $coid1 = mysql_result($objRS, 0,"Clients.id"); $status1 = mysql_result($objRS, 0,"Clcontacts.status"); echo $email." ".$uid1." ".$coid1." ".$status1."<br />"; $value = "myfuckingtime"; setcookie("TestCookie",$value, time()+3600*24*352); setcookie("user", $name1, time()+14400); setcookie("userid", $uid1, time()+14400); setcookie("coid", $coid1, time()+14400); setcookie("login", "yes", time()+14400); setcookie("status", $status1, time()+14400); echo "Welcome ".$name1.", You have succesfully logged in.<br /><br />"; $loggedin = $_COOKIE["login"]; echo $loggedin; } } } else { ?> <h2>Log In</h2> <form action="login.php" method="GET"> <table> <tr><td>user name: (email address)</td><td><input type="text" name="uname" /></td></tr> <tr><td>Password:</td><td><input type="password" name="pass1" /></td></tr> <tr><td></td><td><input type="submit" value="Submit" /></td></tr></table> </form> <? } ?> </div> <div class="post-info"></div> </div> Quote Link to comment https://forums.phpfreaks.com/topic/256308-cookies-not-being-set/#findComment-1313913 Share on other sites More sharing options...
Proletarian Posted February 3, 2012 Share Posted February 3, 2012 In what way is the script failing? Quote Link to comment https://forums.phpfreaks.com/topic/256308-cookies-not-being-set/#findComment-1313914 Share on other sites More sharing options...
guymclaren Posted February 3, 2012 Author Share Posted February 3, 2012 The cookies are not being set period. It gives me the successfully logged in message, but no cookies are available. the rest of the script works as it should. Quote Link to comment https://forums.phpfreaks.com/topic/256308-cookies-not-being-set/#findComment-1313915 Share on other sites More sharing options...
Proletarian Posted February 3, 2012 Share Posted February 3, 2012 Well, for starters, you need to change "<?" these tags to "<?php" tags. Quote Link to comment https://forums.phpfreaks.com/topic/256308-cookies-not-being-set/#findComment-1313917 Share on other sites More sharing options...
guymclaren Posted February 3, 2012 Author Share Posted February 3, 2012 Since when has setting cookies been changing header information? Quote Link to comment https://forums.phpfreaks.com/topic/256308-cookies-not-being-set/#findComment-1313922 Share on other sites More sharing options...
Proletarian Posted February 3, 2012 Share Posted February 3, 2012 Since when has setting cookies been changing header information? What? Quote Link to comment https://forums.phpfreaks.com/topic/256308-cookies-not-being-set/#findComment-1313933 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.