sub init() ... does this have any special purpose?

2002-06-11 Thread Mark Korey

I was once told that in order for mod_perl CGI code to
work properly all functionality/logic needed to reside
in a function named init(). Now that I'm pouring over
mod_perl documentation  getting things running, I haven't
found any mention of this.

So ... is there any special purpose w/in mod_perl for sub init?
or is it just a common naming convention?
or is it baloney?

Example:
--
#!/usr/local/bin/perl

use CGI;
use HTML::Template;
use DButils;# custom DB wrapper mod
use strict;

use vars qw($cgi, $dbh);
$cgi = new CGI;
$dbh = DButils::loginDB;

init();

DButils::logoutDB($dbh);


sub init {

my $template = HTML::Template-new(filename = template.html,
   global_vars = 1,
   cache = 1);

# ... blah, blah, blah ...

print $cgi-header;
print $template-output;

return 1;

}
--

Thanks,
- Mark
  www.fantasycup.com





Re: Porting to mod_perl and cookies are breaking. Why?

2002-06-10 Thread Mark Korey


We found the problem ... this was an odd one (aren't most!?!).
Turns out that the path (i.e. $cgi-cookie(-path ='/', ...); )
was NOT being set. Guess we assumed that CGI.pm would default it to '/'.
Setting that seemed to do the trick.
We are using CGI.pm and did not need to PerlSetupEnv On.

I'm still not sure why this works differently under mod_perl.

Semi-related to this, isn't $cgi-cookie just an API which
uses $ENV{HTTP_COOKIE}?

What's the big advantage of Apache::Cookie?

I'd like to keep my code as flexible  compatible as possible
so it will run under both standard CGI  mod_perl, at least
while we work the kinks out of our mod_perl configuration.

Thanks.

- Mark
  www.fantasycup.com


On Mon, 10 Jun 2002, Per Einar Ellefsen wrote:

 At 05:43 10.06.2002, Mark Korey wrote:
 ENV{HTTP_COOKIE} does not contain a newly set cookie, often it
 still contains an old value when I try to change it (ie switch to a
 different user).
 Everything else appears to be working fine.

 If you're saying that $ENV{HTTP_COOKIE} is empty, you should set
 PerlSetupEnv On in your Location section. See
 http://perl.apache.org/release/docs/1.0/guide/config.html#PerlSetupEnv

 Could we see your code (an excerpt showing the problem)? You might be doing
 something wrong when trying to set cookies. Furthermore, you should really
 be using CGI.pm, CGI::Cookie or Apache::Cookie for your cookie needs.


 --
 Per Einar Ellefsen
 [EMAIL PROTECTED]