Gentlemen, help, please, does not work:

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

    1 answer 1

    If you decide to call the php function from javascript, it will not work. Better this way:

     <a href="?clear">Очистить</a> <- главное - передать в $_GET переменную clear ... <? if(isset($_GET['clear'])){ unset($_SESSION['cart']); } ?> 
    • No, not java - DiTso
    • 3
      What - not java? - ling
    • one
      DiTso you are clearly mistaken. @ling described you absolutely working way. Unlike yours. <? function clear () {..}?> - you described the function in php ... onclick = clear ()> "; - you call the clear function from javascript - stck