php session variable is not updating in jquery
Get the solution ↓↓↓I am trying to update php SESSION variable in jquery mouse event but it is not updating. My jquery function is as follows:
$(document).mousemove(function(e){
<?php $_SESSION['last_activity_time'] = time(); ?>
alert('<?php echo date("H:i:s", $_SESSION['last_activity_time']); ?>')
});
I even used time() function in alert box to check and even with that every time I move the mouse i got the same time. The mousemove function is working since every time i moved it a alerbox shows. But every time the time is same. I don't know what I am doing wrong here...
In some post I found that I can use ajax for updating the session variable. But in that process , what i know(not an expert in ajax) is that the ajax call will goto other page and after performing desired function it return to the current page and I dont want to redirect to soem other php page. I want to update this session variable without moving to other page.
Kindly point out what i am doing wrong in above function and how i can solve this problem.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: npm err! code 1
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.