HTML a href
link:
<a href="#" id="clickme">Update Session</a>
jQuery codes:
You can send data with line of data: { varname: 'here we go'}
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$("#clickme").click(function(e) {
e.preventDefault();
$.ajax({
type:'POST',
url:'update.php',
data: { varname: 'here we go'},
success:function(response){
alert(response);
}
});
});
</script>
update.php file:
You can get sent var with $_POST["varname"]
<?php
$_SESSION["varname"] = $_POST["varname"];
echo $_SESSION["varname"];
?>