|Perl: the Markov chain saw|
Outputting a cookie with session ID in it has got way way less overhead than having to output each file with changed contents.
Failing that you might want to look to see if there is an Apache module that would let you do what you want. There are certainly output filters which can modify the output the server sends after generation - and that would be a good hook to use.
In reply to Re: Adding sessionid to all links in HTML-document