Re: cookie setting/retieval
Enrico, If I do migrate to Apache::SessionManager will this problem disappear? I started looking into the transformation and it appears as if it will be a good bit of work to accomplish the entire cutover and I just want to make for sure that it's not something I'd have to build into my app anyway. The reason I ask is because I was having some trouble with the configuration? After putting the following into the httpd.conf file ## BEGIN CONFIGURATION PerlRequire /usr/local/apache/conf/startup.pl PerlWarnOn PerlFreshRestart On PerlModule Apache::SessionManager PerlTransHandler Apache::SessionManager Alias /perl /usr/local/apache/cgi-bin Location /perl SetHandler perl-script PerlSendHeader On PerlHandler Apache::Registry PerlSetVar SessionManagerTracking On PerlSetVar SessionManagerExpire 120 PerlSetVar SessionManagerInactivity 900 PerlSetVar SessionManagerName SESSION_ID PerlSetVar SessionManagerStore File PerlSetVar SessionManagerStoreArgs Directory = /tmp/sessions PerlSetVar SessionManagerDebug 0 Options ExecCGI allow from all /Location and using the code ## BEGIN CODE sub validate { my $r=shift; my $cgi=new CGI; my $session = Apache::SessionManager::get_session($r); if (($$session{logged_in} eq Y)){ return $session; }else{ print $cgi-redirect('http://' . $ENV{HTTP_HOST} . '/perl/sess.cgi'); return $session; } } I always get the error: Can't locate object method pnotes via package package_name at /usr/local/lib/perl5/site_perl/5.8.0/Apache/SessionManager.pm line 202, TheFile line 28. I'm sure I'm going about something wrong, but I seem to have hit a roadblock.do I need to write my own handler for this? thnx, ~j - Original Message - From: Enrico Sorcinelli [EMAIL PROTECTED] To: Jason Jolly [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 1:52 AM Subject: Re: cookie setting/retieval On Mon, 31 Mar 2003 18:11:21 -0600 Jason Jolly [EMAIL PROTECTED] wrote: I'm currently in the process of writing a wrapper for a site using Apache::Session and mod_perl. I was having great success using the following code to either validate a cookie which was already present or set a new cookie if necessary: Hi Jason, don't reinvent the wheel! ;-) There's already an Apache::Session wrapper on CPAN called Apache::SessionManager. Apache::SessionManager is a mod_perl module that helps session management of a web application. It creates a session object and makes it available to all other handlers transparenlty. Also session expiration policies are available. http://cpan.org/modules/by-module/Apache/Apache-SessionManager-0.04.tar.gz See perldoc Apache::SessionManager for more infos. by - Enrico
cookie setting/retieval
I'm currently in the process of writing a wrapper for a site using Apache::Session and mod_perl. I was having great success using the following code to either validate a cookie which was already present or set a new cookie if necessary: my $r = Apache-request; my $cookie = $r-header_in('Cookie'); my $cgi = new CGI; $cookie =~ s/SESSION_ID=(\w*)/$1/; # create the session from the cookie or create a new one my %session; tie %session, 'Apache::Session::File', $cookie, { Directory = '/tmp/sessions', }; my $session_cookie = "SESSION_ID=$session{_session_id};"; $r-header_out("Set-Cookie" = $session_cookie); Now...this works like a charm, passing the cookie and reading the sessionas long as all of the pages are on the same level of the tree...i.e. : http://www.yoursite.com/perl/hithere.cgi http://www.yoursite.com/perl/ilovecookies.cgi http://www.yoursite.com/perl/monkey.cgi Howeveras soon as you move to anything below that: http://www.yoursite.com/perl/cookies/bananna.cgi http://www.yoursite.com/perl/cookies/arenolongercool.cgi I receive the following error (from the error_log): "Died at /usr/local/lib/perl5/site_perl/5.8.0/Apache/Session/Generate/MD5.pm line 40" By using Mozilla's cookie manager I see that the path attribute of the cookie set in the browser is changed from: "/perl/" to: "/perl/cookies/" ...but I can't seem to figure out why Apache::Session isn't using the combination of the SESSION_ID and the directory stated in the tie() (/tmp/sessions) to retrieve the cookie...the SESSION_ID hasn't changed? Thnx much! ~j
Addition of directory to @INC variable via startup script/mod_perl
I currently have the following configuration in my httpd.conf file: PerlRequire /usr/local/apache/conf/startup.pl Alias /perl/ /usr/local/apache/cgi-bin PerlTaintCheck On PerlWarn On PerlFreshRestart On PerlTransHandler Apache::SessionManager PerlFreshRestart On Location /perl SetHandler perl-script PerlSendHeader On PerlHandler Apache::Registry Options ExecCGI /Location And here are the contents of the startup.pl script: #!/usr/bin/perl use strict; use lib qw(/usr/local/apache/require); use Apache::Registry(); use CGI(); use CGI::Session(); use CGI::Carp(); use DBI(); use Net::LDAP(); $ENV{MOD_PERL} or die "not running under mod_perl!"; 1; When I stop/start the server and run a script with the following code: foreach $item (@INC) { print ($item . "br"); } I only get the output: /usr/local/lib/perl5/5.8.0/sun4-solaris /usr/local/lib/perl5/5.8.0 /usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris /usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl . ?? I can't seem to find any rhyme or reason why the directory "/usr/local/apache/require" isn't on the @INC array? Any help is greatly appreciated.according to all documentation I can find this should actually work. I'm hoping that I'm doing something terribly stupid :). thnx, ~j