Unset ($ _ session [‘Cart’])

Gentlemen, please, please do not work:

<?
function clear() {
$_SESSION['cart'] = array();
unset($_SESSION['cart']);
}
?>
<? 
echo "<input type=button value='' onclick=clear()>";
?>

Answer 1, Authority 100%

If you decide to call the PHP function from JavaScript, it will definitely not work. Better like this:

<a href="?clear"></a> <-  -   $_GET  clear
...
<?
if(isset($_GET['clear'])){
    unset($_SESSION['cart']);
}
?>