I need to update the session variable on page 1, when click on a link in iframe (external page). session variable is successfully set when i click on iframe's link. the problem is i need to refresh the page 1 to update that session variable on page1.
how to resolve this.any ajax , jquery help. THanks
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"];
?>