hey guys, thanks for your replies!
it looks like the function is actually called "session_write_close" not "write_session_close"

but it's not helping me!
I really don't understand what's happening with my code and it's getting frustrating!
basically i have one page that displays the results of a sql query (using MySQL 5). these results are always fetched every time the page loads - it is not cached in session. it also should not be cached in the browser because I added:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
then I have a button the user may click to delete these records which does this:
Code: Select all
if (isset($_POST['action'])) {
if ($_POST['action'] == 'delete') {
// perform SQL DELETE
$_SESSION['msg'] = 'some message';
session_write_close();
header("Location: mypage.php");
}
}
then in my html I do:
<? if (isset($_SESSION['msg'])) { ?>
<p class="info"><?= $_SESSION['msg'] ?></p>
<? unset($_SESSION['msg']);
<? } else { ?>
// display records
<? } ?>
but what happens is when I press the button to initiate this delete, the page refreshes with the same records displayed. It should have deleted these records, put that msg in session and then display the msg on first redirect (where it is then taken out of session).
there is no other code here that can confuse things, its very simple.
I can sit the refreshing the page several times and it continues to display the deleted records. I can confirm in mysql these records are in fact gone. finally after just sitting there refreshing the page several times it realizes the records are gone and then does not display anything.
it is so weird...
it's as if there is this long delay between sql and php or there is some other cache.
what could be going on?