I want to create php session when mouse is moved at least once then no need to do anything if mouse keeps moving
I am using this code but its not solving the requirement
<script type="text/javascript">
jQuery(document).ready(function()
{
$(document).mousemove(function(e)
{
$('#status').html(e.pageX);
$('#status1').html(e.pageY);
$.ajax({
type: 'POST',
url: 'second.php',
data: {
'x': '10',
'y': '20'
},
success: function(msg){
//what you want after request
}
});
});
});
</script>
</div>
The PHP code should be something like this:
session_start();
if (!isset($_SESSION['mouseMoved'])
$_SESSION['mouseMoved'] = "whatever you want";
Also, you should set some variable in JS so that the request is only sent to the server once.
Updated: a working jsfiddle https://jsfiddle.net/bqh0yrtp/