You need to call $PAGE->set_url with the best URL for re-loading the current page. Think permalink.
This is necessary for things like editing blocks, or turning editing on or off, where after some action is taken you need to be able to redirect back to the current page - but without junk like sesskey in the URL.
I have the same experience. You can put anything, but you should put the right thing
When I am writing little utility scripts, that don't pass values via the query string, I use the following generic code near the top of a Moodle 2.0 script:
It seems to work OK, probably in "real" scripts, we are supposed to set the url explicitly, and pass the query string params too.
However, I could be miles off ...
$url = new moodle_url('/course/report/completion/index.php', array('course'=>$course->id));
which presumably is a convenience feature.
moodle_url is a very handy class, and it is the recommended way to deal with URLs whenever possible.