views:

426

answers:

2

When displaying data from DB usually I'm in this situation

  1. I'm in page A.php that shows data from DB,
  2. user performs some action (like edit/delete etc) and page B.php is loaded to perform the action,
  3. once page B performed the action, it redirects browser to page A,
  4. page A is auto reloaded during step (3) therefor it shows an updated situation of the data

In order to make page B to redirect to page A i use a simple PHP

header("Location: " . "A.php", TRUE, 302);

This works well in all situations, except when pages A.php is displaied into an <iframe>: in such a case it does not reload (step 4 does not get done). This seems to happen only in IE7 (don't know about IE8), it works perfectly on FF/Safari. And only when using an <iframe>, if page A.php is not in <iframe> it gest refreshed also in IE7.

In order to solve this I simply added a couple of headers in page A.php to set it to not be cached:

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

But I was curious if you might have experienced the same issue too in the past, and if you coud give me some advice about this?

A: 

Are you using sessions? If so, can you test your scenario again without session and without your fix?

The fix you made deal with cache control and expiration, which is altered by session_start() and/or session_cache_limiter(). Still, that behavior is strange, that could be an IE-7 specific bug.

Savageman
No, not using sessions.
Marco Demajo
A: 

Is content in the same domain as "outside" frame?

If not, you might need to supply the full path "http://...etc." in header() call.

Milan Babuškov
Yes, same domain!
Marco Demajo
I always suppluy full urls in header it's HTTP requiremnts.
Marco Demajo