Voodoo Jai Posted September 26, 2008 Share Posted September 26, 2008 I have a page that is supposed to set a cookie but when I check the cookies its not there. part of the code is here: <?php if($_GET["action"] == "2"){ $username = $_POST["username"]; $password = $_POST["password"]; $referrer = "http://host.com"; if($username == "username" && $password == "password" && str_replace("www.", "", $_SERVER['HTTP_REFERER']) == $referrer."statistics2.php") { setcookie("JumboJai", "poochimasta", 0); } } ?> If I set the cookie not to be TRUE then my page does what its supposed to: <?php if($_COOKIE["JumboJai"] != "poochimasta") { mysql_select_db($database_host_conn, $host_conn); echo "COOKIE WORKING"; ?> I'm confused.com LOL VoodooJai Quote Link to comment https://forums.phpfreaks.com/topic/125941-solved-cookie-not-being-set-by-page/ Share on other sites More sharing options...
thebadbad Posted September 26, 2008 Share Posted September 26, 2008 Your cookie is only available in the same directory as the script setting the cookie. And it expires when the browser is closed. Is that what you want? Quote Link to comment https://forums.phpfreaks.com/topic/125941-solved-cookie-not-being-set-by-page/#findComment-651217 Share on other sites More sharing options...
Voodoo Jai Posted September 26, 2008 Author Share Posted September 26, 2008 Your cookie is only available in the same directory as the script setting the cookie. And it expires when the browser is closed. Is that what you want? I think so could you explain more. Quote Link to comment https://forums.phpfreaks.com/topic/125941-solved-cookie-not-being-set-by-page/#findComment-651223 Share on other sites More sharing options...
Voodoo Jai Posted September 26, 2008 Author Share Posted September 26, 2008 When I try to view the cookie using FF cookie editor its not there. I dont think its being set by the page as when I set the expression to FALSE it works fine. VoodooJai Quote Link to comment https://forums.phpfreaks.com/topic/125941-solved-cookie-not-being-set-by-page/#findComment-651239 Share on other sites More sharing options...
thebadbad Posted September 26, 2008 Share Posted September 26, 2008 Remember the cookie only is set when the if conditions is met. Check if they are. Quote Link to comment https://forums.phpfreaks.com/topic/125941-solved-cookie-not-being-set-by-page/#findComment-651257 Share on other sites More sharing options...
Voodoo Jai Posted September 26, 2008 Author Share Posted September 26, 2008 After a bit of digging I get this error msg Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/poochima/lostmymenu.com/statistics2.php:3) in /hsphere/local/home/poochima/lostmymenu.com/statistics2.php on line 13 Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/poochima/lostmymenu.com/statistics2.php:3) in /hsphere/local/home/poochima/lostmymenu.com/statistics2.php on line 15 it looks as though it wont let me set the cookie at line 13 of the pagewhy is this. VoodooJai Quote Link to comment https://forums.phpfreaks.com/topic/125941-solved-cookie-not-being-set-by-page/#findComment-651287 Share on other sites More sharing options...
thebadbad Posted September 26, 2008 Share Posted September 26, 2008 Cookies are set with the headers, so you can't have any output to the browser before setcookie(). The error messages say you have. Quote Link to comment https://forums.phpfreaks.com/topic/125941-solved-cookie-not-being-set-by-page/#findComment-651292 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.