Forum Moderators: coopster

Message Too Old, No Replies

problem with a cookie

         

supermanjnk

1:43 am on Jul 27, 2004 (gmt 0)

10+ Year Member



edit: I figured out whats wrong, it's because i have a header right after the cookie, my new question is: is there anyway I can have it run one thing then something else?

if ($num!= "0") {
setcookie("dhananscookiehjj", $username, time()+86400);
header ("location: .../logout_form.php");
exit;
}

could i use:

if ($num!= "0") {
setcookie("dhananscookiehjj", $username, time()+86400);
}
while {
header ("location: .../logout_form.php");
exit;
}

or anything like that?

dreamcatcher

5:08 pm on Jul 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can try using a meta refresh.


function redirect($url)
{
echo "<meta http-equiv=\"refresh\" content=\"4;URL=" . $url . "\">\n";
echo "Please wait....";
exit;
}

then:


if ($num!= "0") {
setcookie("dhananscookiehjj", $username, time()+86400);
redirect('somewhere.php');
}

StupidScript

7:25 pm on Jul 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How about doing the redirect, then checking for a cookie and writing a new one if there is none found:

===checks for valid login===
if ($num!= "0") {
header ("location: .../logout_form.php");
exit;
}

===on logout_form.php===
if (!$_COOKIE["dhananscookiehjj"]) {
setcookie("dhananscookiehjj", $username, time()+86400);
}
...then the rest of the page...