Page 1 of 1

Trouble redirecting after cookie is sent

Posted: Fri Jan 30, 2004 11:38 am
by jestep
Im trying to redirect to a different page depending on whether or not the user has a cookie that was sent to them on a different page.

Here is the Cookie:

<?php
setcookie("affiliate", "washere", time()+60*60*24*30, "/", "merchantequip.com");
?>

Here is the redirect script:

<?php
//If no cookie redirect
if ($_COOKIE["affiliate"] == "washere") {
echo("<meta http-equiv='refresh' content='0;url=sales.php'>");
}else{
if ($_COOKIE["affiliate"] != "washere") {
echo("<meta http-equiv='refresh' content='0;url=sales2.php'>");
}
}
?>

It always redirects to the sales2.php page and I need it to redirect to the sales.php page if the user has the cookie.

Code: Select all

<?php

?>

Posted: Fri Jan 30, 2004 11:40 am
by markl999
Does affiliate appear in a var_dump($_COOKIE); ?
If not then it looks as though the cookie isn't being set.

Posted: Fri Jan 30, 2004 1:22 pm
by jestep
I did a test and found that I am unable to send the cookie at all, I looked through the forum and tried about 10 different methods to test if the cookie was being sent, nothing seems to work.

Im not sure how to use the var_dump($_COOKIE); function, but it sounds like it might be the problem.

Posted: Fri Jan 30, 2004 1:22 pm
by Gen-ik
From the manual......

Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. Expire time is set via the expire parameter. A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);.

Posted: Fri Jan 30, 2004 1:23 pm
by jestep
tried the print_r($_COOKIE);.
no cookies come up,
Cookies are enabled in my browser, and I can see them in my temp folder