July 21st, 2005

nova

Continue shopping button in PHP

I can't believe how easy it is to create a Continue Shopping button!

session_start();

// If referrer is not itself, make session variable the referrer.
if ( strpos( $_SERVER["HTTP_REFERER"], 'cart.php' ) === false )
{ $_SESSION[continueShopping] = $_SERVER[HTTP_REFERER]; }

 if ( $_SESSION[continueShopping] ) {
    print "<a href='{$_SESSION[continueShopping]}'>Continue Shopping</a>\n";
}

It's that easy!