Dear all,

There are 3 php pages namely login.php, modify.php and result.php.

  • login.php 'POST' username and pwd to select.php
  • valid user can modify his profile from ldap server in select.php
  • result.php shows old and new profile

The problem is when I make back and forth among the pages, ' The page cannot be displayed' error occured in all pages except login.php.

I have already added these lines in the very start of every php pages. Can anybody give the idea to fix it ??

session_start();
header("Cache-control: private"); // IE version is 6.0

    ive had that problem too.

    usually the cache-control: private fixes it, but ive had it still randomly do it.

    i cant find any pattern to it either. one thing that did seem to help was adding a query string to the form action

    <form action="foo.php?fakevar" method="post">

    it still does it occasionally though. damn IE

      yes! everything is fine in netscape browser. IE made me difficult. 🙁

        Try these

        //disable all browser caching MUST BE FIRST LINES WITH NO PRECEEDING SPACES ETC
        // Date in the past
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        
        // always modified
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        
        // HTTP/1.1
        header("Cache-Control: no-store, no-cache, must-revalidate");
        header("Cache-Control: post-check=0, pre-check=0", false);
        
        // HTTP/1.0
        header("Pragma: no-cache");
        

        Works for me with IE all versions as well as Firefox & Netscape.

          Thank you so much. I have already tried it.. But it still doesnt work in IE. 🙁

          <?php
          session_start();
          header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
          header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
          header("Cache-Control: no-store, no-cache, must-revalidate");
          header("Cache-Control: post-check=0, pre-check=0", false);
          header("Content-Type:text/html;charset=UTF-8");
          .....

            Read the comments in my code. They are not there to just make it look pretty, they actually mean what they say. Then look at your code and figure out what you are doing wrong.

              I DID read your comments. I changed some lines hoping it will mork. Recently I have placed them back in very first line of php page. But it still doesnt not work. Really sorry ..

                Think about it. The first thing you need to send to the client is the cache-control, otherwise the browser's default values will already have come into effect. Your code has session_start() = send a cookie to the browser before the cache statements.

                I use these headers for a db driven web application that I have tested on IE 5 & 6 as well as Firefox, Netscape etc and have no problems with any of them.

                If you have been sending pages without cache control then they will already be in browser cache and can prevent the new settings from taking effect in a piece of garbage like IE. Clear the cache and cookies on your test system and then try it. If there is a proxy in the picture then this can also trip you up.

                  5 days later

                  Dear Roger Ramjet,

                  Here is correct sequence for IE6

                  header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                  header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                  header("Cache-Control: no-store, no-cache, must-revalidate");
                  header("Cache-Control: post-check=0, pre-check=0", false);
                  session_start();
                  header("Cache-Control: private");

                  if the last header is placed above session_start() OR the upper ones are placed below session_start(), (my) IE doesnt work for back and forth.

                  the upper headers are to work like you explained and the last one is to fix I IE6 private cache control problem.
                  Now users can hit the back button and change information all they want! Wow... no need to sweat any more. 🙂

                  Again many thanks..

                    4 months later

                    I am trying to create a system where a user can upload and image and a flash page will dynamically show that file. Everything is working fine, exept for the IE cache thing - netscape, firefox - no problem.

                    I have tried a million and one things and this seems the most promising. When I try to put the session_start(); in my code I get errors - without it... cache problems.

                    here is my php:
                    <?php
                    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                    header("Cache-Control: no-store, no-cache, must-revalidate");
                    header("Cache-Control: post-check=0, pre-check=0", false);
                    session_start();
                    header("Cache-Control: private");

                    if(isset( $Submit ))

                    {

                    $var = md5(time());
                    $picture_name = "image.jpeg?var=".$var;

                    switch($FILES['imagefile']['type']) {
                    case 'image/jpeg':
                    case 'image/pjpeg':
                    $orig = imagecreatefromjpeg($
                    FILES['imagefile']['tmp_name']);
                    break;
                    case 'image/png':
                    $orig = imagecreatefrompng($FILES['imagefile']['tmp_name']);
                    break;
                    case 'image/gif':
                    $orig = imagecreatefromgif($
                    FILES['imagefile']['tmp_name']);
                    break;
                    default:
                    $error = 'Unknown File Format or MIME Type';
                    $show = 'error';
                    echo "Wrong Filetype E1";
                    }

                    if($orig) {

                    $orig_x = imagesx($orig);
                    $orig_y = imagesy($orig);
                    $image_x = 200;
                    $image_y = round(($orig_y * $image_x) / $orig_x);
                    
                    $image = imagecreatetruecolor($image_x, $image_y);
                    imagecopyresampled($image, $orig, 0, 0, 0, 0, $image_x, $image_y, $orig_x, $orig_y);
                    
                    
                    imagejpeg($image, "images/". 'image.jpeg');
                    
                    echo "upload done!!!"; 
                    
                    
                    
                    }

                    else {
                    if(!$error)
                    $error = 'Error reading uploaded image';
                    $show = 'error';
                    echo "Wrong Filetype E2";
                    }

                    }

                    ?>

                    and the errors:

                    Warning: session_start(): open(/tmp/php-ses/sess_f96b0feb611f10312a4ad92fba3bdb1f, O_RDWR) failed: No such file or directory (2) in /nfs/cust/7/04/28/582407/web/imagesize.php on line 6
                    Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /nfs/cust/7/04/28/582407/web/imagesize.php:6) in /nfs/cust/7/04/28/582407/web/imagesize.php on line 6
                    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /nfs/cust/7/04/28/582407/web/imagesize.php:6) in /nfs/cust/7/04/28/582407/web/imagesize.php on line 6
                    Warning: Cannot modify header information - headers already sent by (output started at /nfs/cust/7/04/28/582407/web/imagesize.php:6) in /nfs/cust/7/04/28/582407/web/imagesize.php on line 7upload done!!!
                    Warning: Unknown(): open(/tmp/php-ses/sess_f96b0feb611f10312a4ad92fba3bdb1f, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
                    Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp/php-ses) in Unknown on line 0

                    thx for any help!

                      Write a Reply...