Re: Execute php with back button



zek2005 wrote:
I need that when the user goes back to the last page with the "Back"
button of the browser, the page executes the php code again.

Is there any code to insert in php that implies a reload every time the
page appears in the user browser??



Simply disable caching:

<?php

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

session_start();
if (!session_register("var")) {
    session_register("var");
    $_SESSION["var"] = 1;
} else {
    $_SESSION["var"]++;
}

echo $_SESSION["var"];

?>

This will output 1 on first load,
Go to some other site, then hit back, and it will output 2 :)


luph .


Quantcast