Gentlemen, help, please, does not work:
<? function clear() { $_SESSION['cart'] = array(); unset($_SESSION['cart']); } ?> <? echo "<input type=button value='Очистить' onclick=clear()>"; ?>
Gentlemen, help, please, does not work:
<? function clear() { $_SESSION['cart'] = array(); unset($_SESSION['cart']); } ?> <? echo "<input type=button value='Очистить' onclick=clear()>"; ?>
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']); } ?>
Source: https://ru.stackoverflow.com/questions/26824/
All Articles