Log in

View Full Version : header function don't work immediately?



writeman
03-29-2007, 04:20 AM
hi all
my php script named aa.php and in the top of script I write

<?php
if($cookie_userid=='' || $cookie24 == ''){
header("Location: http://192.168.1.253/login.html");
exit();
}
?>

but when I don't set the cookie24 and change the IE url to "http://192.168.1.253/aa.php", I get the aa.php page.
Because I have cache the aa.php page in my IE.
the header("Location: http://192.168.1.253/login.html"); code don't work immediately.
Can I make it work immediately and not to get the cache page??

thetestingsite
03-29-2007, 04:26 AM
Try placing this at the very top of the code (underneath the opening php tag):



header("Cache-Control: no-cache, must-revalidate");


Hope this helps.

writeman
03-29-2007, 06:05 AM
I haved give up the method and changed to the method below.
It seems work but I don't know if the have any ill effect?

<?php
if($cookie_userid=='' || $cookie24 == ''){
echo '<script language="javascript">window.location.replace("http://192.168.1.253/login.html");</script>';
exit();
}
?>

codeexploiter
03-29-2007, 06:16 AM
I haved give up the method and changed to the method below.
It seems work but I don't know if the have any ill effect?

<?php
if($cookie_userid=='' || $cookie24 == ''){
echo '<script language="javascript">window.location.replace("http://192.168.1.253/login.html");</script>';
exit();
}
?>


What if your visitor's JavaScript is turned off? You could've troubleshoot the PHP problem.