Perl Cd Bookshelf [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Perl Cd Bookshelf [Electronic resources] - نسخه متنی

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



21.11. Communicating Between mod_perl and PHP


21.11.1. Problem


You want to build your
site from both mod_perl and PHP. For example, you might want to use
mod_perl for authentication and logging, while PHP generates the
actual content. However, doing so means that Perl and PHP must share
values; for example, so the PHP content handler knows which username
successfully authenticated through mod_perl.

21.11.2. Solution


Use Apache notes. From Perl, you simply say:

$main = $r->main || $r;
$main->notes($KEY => $VALUE);
$VALUE = $main->notes($KEY);

From PHP, you say:

apache_note($KEY, $VALUE);
$VALUE = apache_note($KEY);

21.11.3. Discussion



A
note is a string value attached to an Apache
request. They're a perfect way to pass information between handlers,
even when those handlers are written in different programming
languages. Each request has a different set of notes, so from Perl
always identify the main request and use it to communicate with PHP
code.

Don't confuse the $r->notes method with the
$r->pnotes method. The latter is only available
to Perl modules.

21.11.4. See Also


Recipe 21.10



21.10. Transparently Storing Information in URLs21.12. Migrating from CGI to mod_perl




Copyright © 2003 O'Reilly & Associates. All rights reserved.

/ 875