From: "Collin Monahan" <[EMAIL PROTECTED]>
I'm trying to learn how to use mod_perl2 along with Ajax. Everything was
humming along until it seemed like perhaps Apache had a couple instances
of my handler in memory, and what I had declared as module variables were
existent in two different states. It seemed like Apache was handing off to
a different handler each time my Ajax callbacks were invoked on
browser/user input, and the handler chosen was somewhat at random. Perhaps
I could try to exemplify what I was seeing.
Under mod_perl, packages/scripts remain in memory across requests, for the
duration of the Apache child. So in something like this, each time the
handler is invoked, the $counter will continue growing with each new
request... whether it's after numerous requests by one user or numerous
users issuing one request each:
package Somepackage;
my/our $counter = 0;
sub handler {
$counter++; #
$r->print($counter);
}
The second issue is that, due to the stateless nature of HTTP, requests are
dispatched to Apache/mod_perl children at random. You can't store
information about a particular user or user's session in a perl variable and
expect that user's next request to be sent to the same Apache/mod_perl
process. This is why there are so many modules and techniques for storing
user session/state information using various files and databases. Ajax has
nothing to do with it, it does not change any of this. All Ajax does is send
"normal" HTTP requests to the server, just without reloading the entire
page.