Please bear with me, I need help.
On my site:
-
index.php – displays 20 links in this form:
$result = mysql_query("my query"); while($slice = mysql_fetch_assoc($result)){ $url = $slice['url']; $perf = $slice['perf']; <a class="ajaxquery" data-title="<? echo $perf; ?>" href="$<? echo $url ?>">anchor</a> endwhile; -
If someone clicks on one of the 20 links, I have this ajax code, which see’s which
$perfis clicked, sending the data tosession.php:function ajaxsession(){ $("a.ajaxquery").click(function() { var perf = $(this).data('title'); $.ajax({ type: "POST", url: "/session.php", data: "perf="+perf, success: function(html){ $("#results").append(html); } }); }); } -
This code sends the following to
session.php:session_start(); $_SESSION['perf'] = $_POST['perf']; // Store session data -
And on my
single.phppage I call the variable stored in the session:echo $_SESSION['perf'];
On single.php I get the right $perf as long as I get back to index.php using the home link.
If I get back to index.php using the browsers back arrow, then the $perf is not updated using the onclick jQuery code.
Do you have any ideas on why is this happening? I am thinking that maybe I should destroy the session somehow once it reaches single.php. Is that a good idea?
‘back button’ will usually return to and load a cached copy of the page. If you need to have that “previous” page automatically reload when the user goes “back” to it, you’ll have to send out that page with no-cache headers when it’s first loaded.