Results 1 to 4 of 4

Thread: header function don't work immediately?

  1. #1
    Join Date
    Mar 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default header function don't work immediately?

    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??

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Try placing this at the very top of the code (underneath the opening php tag):

    Code:
    header("Cache-Control: no-cache, must-revalidate");
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Mar 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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();
    }
    ?>

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Quote Originally Posted by writeman View Post
    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •