Reset javascript back history counter

I’m trying to rest the javascript back history counter in my code back to 0 if I come to my cart.php page from another page on my site. Everything’s working the way I want it to right now except I can’t get the counter to reset. I’m loading the page in an Iframe in my shop with java script if the referrer equals the cart.php itself otherwise I load a referrer link with javascript. The counter keeps indexing on a cart update and when I come back to it from another page. I need it to rest to 0 when I come from another page but keep counting the way it does now on a cart.php refresh or update. Any thoughts would be greatly appreciated.
[php]<?php
session_start();
$referer = $_SERVER[‘HTTP_REFERER’];

$mystringa = '<a style="text-decoration:none; color:inherit; font-family:inherit; font-size:25px;" href="javascript:history.go(';
$mystringb = ')" title="Return to the previous page">&laquo; Continue Shopping </a>';

if ( $referer != “http://mydomain.com/shop/cart.php” ) {
unset($_SESSION[‘refresher’]);
}

else  if (!isset($_SESSION['refresher']))    {
	$_SESSION['refresher'] = 0;

	}

else    {
	$_SESSION['refresher']--;

}


?>
Refresher

<?php echo $mystringa; echo $_SESSION['refresher']-1 ; echo $mystringb; ?> [/php]

i don’t understand you mean…

I got it working by changeing the code a little then adding the second code to other iframes being loaded by my other site pages to end the session. This would reset the counter when ever I came to the cart.php from somewhere else in my site.
[php]<?php
session_start();
$referer = $_SERVER[‘HTTP_REFERER’];
$mystringa = '« Continue Shopping ';

  if (!isset($_SESSION['refresher'])) {
      $_SESSION['refresher'] = -1;
     }

  else    {
      $_SESSION['refresher']--;
     }

?>

Refresher <?php echo $mystringa; echo $_SESSION['refresher']-1 ; echo $mystringb; ?> [/php]

End SESSION
[php]<?php
session_start();
if(isset($_SESSION[‘refresher’]))
unset($_SESSION[‘refresher’]);
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service