You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Eric Ricardo Anton <er...@telcomanager.com> on 2003/07/20 23:15:39 UTC

Calling a mod_perl method from whithin a CGI script

	I have started using Apache::AuthCookie, which runs under mod_perl, for 
authentication. The problem is that the whole website I’m working on is 
based on mod_cgi. I need the CGI scripts to call a mod_perl method in 
order to recognize the user that is logged in.

	Since I can't port the scripts from mod_cgi to mod_perl, how can I make 
a CGI script call a mod_perl method?

	Thanks for any help.

	Eric



Re: Calling a mod_perl method from whithin a CGI script

Posted by Perrin Harkins <pe...@elem.com>.
On Sun, 2003-07-20 at 17:15, Eric Ricardo Anton wrote:
> 	Since I can't port the scripts from mod_cgi to mod_perl, how can I make 
> a CGI script call a mod_perl method?

You can't.  When you run a script under mod_cgi, mod_perl functions are
not available.  However, you could try running your scripts under
Apache::Registry, and then you'd be able to use the mod_perl API.

- Perrin

Re: Calling a mod_perl method from whithin a CGI script

Posted by Stas Bekman <st...@stason.org>.
Eric Ricardo Anton wrote:
> 
>     I have started using Apache::AuthCookie, which runs under mod_perl, 
> for authentication. The problem is that the whole website I’m working on 
> is based on mod_cgi. I need the CGI scripts to call a mod_perl method in 
> order to recognize the user that is logged in.
> 
>     Since I can't port the scripts from mod_cgi to mod_perl, how can I 
> make a CGI script call a mod_perl method?
> 
>     Thanks for any help.

let's say you have a script:

print "Content-type: text/plain\n\n";
print "Hello whoever you are\n";

now you change it to be:

my $r = shift;
my $username = $r->connection->user || '';
print "Content-type: text/plain\n\n";
print "Hello $username\n";

or:

my $r = Apache->request;
my $username = $r->connection->user || '';
print "Content-type: text/plain\n\n";
print "Hello $username\n";

This is correct for mp1.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com