You cannot call PHP functions after the page has finished loading. PHP is a server technology and runs on a server, not on a client computer. This means that you cannot call the PHP function without sending the details to the script.
If you try to call the unset function when the user clicks the link, you can create a link to the script where you cancel the $_SESSION variable:
<span><a href='somepage.php?somevar=42'>foo</a></span>
When the user clicks on the link, they will be sent to somepage.php . Now you can check if the somevar key is somevar , and then unset session in the script:
<?php session_start(); if (isset($_GET['somevar'])) { unset($_SESSION['vertical']); }
If you want to do this without refreshing the page, you can take a look at AJAX .
Amal Murali Dec 22 '13 at 16:08 2013-12-22 16:08
source share