I have a button which successfully triggers a "load more" on click. Once it is clicked, a SESSION variable is set, so that when the user reloads the page, the new posts should appear loaded already, so that the user does not need to click again "load more".
I would thus like to render the same "load more" Javascript function in a PHP IF statement, according if a SESSION or COOKIE is set or not:
<?php
if ((isset($_SESSION['isloaded'])) || (isset($_COOKIE['isloaded']))){
echo '<script>loadmore(\'posts\');</script>';
}
else {
echo '<a href="#" onClick="return false" onmousedown="javascript:loadmore(\'posts\');" class="btn btn-primary" id="load-more-btn">Load More</a>';
}
?>
However the Javascript does not get triggered once the page is rendered. What am I doing wrong?