onlick is a client side action. php runs on the server. for this to happen, you onclick would need to submit either via post or get to a php script on the server.
something like...
<?php
if (isset($_GET['fav'])) {
$_SESSION['numb'] = $_SESSION['numb']+1;
$_SESSION['xxx'.$_GET['fav']] = $_GET['fav'];
}
?>
and your links
<a href="<?= $_SERVER['PHP_SELF'] ?>?fav=34">add to session</a>