[development] Alternative to hook_exit

mark burdett mfburdett at gmail.com
Thu Apr 19 08:34:47 UTC 2007


One of the output buffering tricks described on
http://us2.php.net/register_shutdown_function works with drupal.  Note
for this, drupal caching needs to be off since cache.inc already has
its own ob_end_flush().

add this at the top of drupal index.php:
header("Connection: close");
ob_start();

and at the bottom add this:

$size = ob_get_length();
header("Content-Length: $size");
ob_end_flush();
flush();
drupal_set_message(date('r'));
sleep(15);
drupal_set_message(date('r'));

You can see that the session is still alive 15 seconds after you
finished loading the page, and it adds a message which will display on
subsequent page loads.

--mark

On 4/18/07, David Metzler <metzlerd at metzlerd.com> wrote:
> Thanks everyone for the ideas.
>
> Current'y my code is caching data in session variables.
>
> Still haven't quite found an elegant solution. I am doing caching,
> but I'm currently caching to session variables. I can't quite figure
> out how to get either the register_shutdown or exec calls to cache
> data easily.   $_SESSION variables don't appear to be available in
> either mechanism.  I haven't tested exec, but that's true, right?
>
> The register_shutdown page suggested a hack to basically load an
> invisible .gif file from a script page and have the code that
> generates the gif alter the session variables.
>
> If you've got a more elegant solution, please share.....
>
> Dave
>
> On Apr 17, 2007, at 2:20 PM, Ken Rickard wrote:
>
> > Dave-
> >
> > Are you caching those webservice calls?  That would be the first
> > option.
> >
> > Otherwise, the approach depends on what those calls do.
> >
> > - Ken Rickard
> > agentrickard
>
>


More information about the development mailing list