2
var x = e.pageX;
var y = e.pageY;

Which is the easiest way to save those jQuery variables in a PHP session.

2

2 Answers 2

5
$.ajax({
   url: '/update-session.php',
   data: {"x":e.pageX,"y":e.pageY},
   type: 'post',
   success:function(data){
       // if you care. 
   }
});

update-session.php:

$_SESSION['pageX'] = $_POST['x'];
$_SESSION['pageY'] = $_POST['y'];

http://api.jquery.com/jQuery.ajax/

Sign up to request clarification or add additional context in comments.

2 Comments

No they couldn't. The session keys are declared in the PHP file.
Dude, look at the code. JavaScript is not setting the session keys.
1

Make an AJAX request to a PHP page that saves them in the session.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.