I've been searching for an answer to this for a long time, but found absolutely nothing. Obviously some AJAX has to be used, possibly setting some session variables, but everything I've tried has failed. Does anyone have a clue on how to do this?

My code is too large, but I'll give you a small example, in case you need one:

Code:
<?php
{
   //first part of code
}

//endless loop,
...