osdir.com
mailing list archive F.A.Q. -since 2001!



Subject: Apache::Cookies - problems with cookies -
msg#00214

List: apache.mod-perl

Mail Archive Navigation:
by Date: Prev Next Date Index by Thread: Prev Next Thread Index

Hi there folks,
I'm just getting back into some mod_perl after a fairly lengthy absence,
and I'm running into some troubles with cookies.

Basic summary- I'm trying to set a session ID in a cookie, and it works only
if I do not include an expiration time.

Details:

-------------snip--------------------
%r_cookies = Apache::Cookies->fetch();
if ( $r_cookies{'session'} ) {
Apache::warn('cookie found.');
$r_sessid = $r_cookies{'session'}->value();
$r_cookies{'session'}->bake();
} else {
my $sessid = create_new_session();
Apache::warn('cookie created.');
$cookie = Apache::Cookie->new($r,
-name => 'session',
-value => $sessid,
-expires => '+7d',
-domain => '.mydomain.com',
-path => '/cgi'
);
$cookie->bake();
}
-------------snip--------------------

Ok, that's the example code. Here's what I'm experiencing.
With the code as you see it, every time I hit a page, I get a message in the
log saying that I created a cookie, even though netscape tells me that I'm
modifying an existing cookie on reloads. Netscape sees the cookie, but my
code isn't finding it in the fetched cookies.

If I make one modification to this code- remove the "-expires => '+7d',"
from the cookie creation, remove all cookies from netscape and go look at my
site, everything works perfectly, except that the cookie only lasts until
the browser gets closed. I'd like to have a bit more persistence than that.

Anyone care to explain how I'm being an idiot? I'm sure I'm missing
something here, just not certain what.

Additionally, anyone got good solutions for looking at the headers being
sent to your browser along with a page, besides using a sniffer? I would
find it useful to check what's being sent to my browser from other web sites
and compare it to what I'm generating to see what I can learn.

Thanks
--Ross Becker





Thread at a glance:

Previous Message by Date:

Re: mod_perl PerlAccessHandler/PerlAuthenHandler question

How is your mod_perl configured? Based on the error message you're getting, it appears that you may not have compiled in support for authentication or access control. If you built it yourself, you may need to add PERL_AUTHEN=1 and PERL_ACCESS=1 to the 'perl Makefile.PL' command line when building mod_perl. Unless you have reason not to, I'd recommend that you compile it with EVERYTHING=1. Steve Piner Harry Zhu wrote: > > I'm a verteran CGIer but a new mod-perl user. > I have got the mod-perl running fine for the content handling. But when I > try to step in to other stages like Authentication, and have trouble in > setting > PerlAccessHandler > PerlAuthenHandler > etc. > > If I put > ###====================== > <Location /mpl/hello> > SetHandler perl-script > PerlHandler Apache::Hello > </Location> > > ###====================== > in the perl.conf file, it's ok. I got the expected from the browser. But > when I changed above to > > ###====================== > PerlModule Apache::AuthAnon > <Location /mpl/hello> > AuthName Anonymous > AuthType Basic > PerlAuthenHandler Apache::AuthAnon > require valid-user > > PerlSetVar Anonymous anonymous|anybody > > SetHandler perl-script > PerlHandler Apache::Hello > </Location> > > ###====================== > > and try to restart the server, I got > Syntax error on line 9 of /usr/local/apache/conf/perl.conf: > Invalid command 'PerlAuthenHandler', perhaps mis-spelled or defined by a > module not included in the server configuration > > When I set up .htaccess in a directory "test" under DocumentRoot, > ###====================== > PerlAccessHandler Apache::GateKeeper > PerlSetVar Gate closed > > ###====================== > and try to access this directory, the server gives the "Internal Error": > /usr/local/apache/htdocs/test/.htaccess: Invalid command > 'PerlAccessHandler', perhaps mis-spelled or defined by a module not included > in the server configuration > > I can add "use Apache::GateKeeper ();" in the startup.pl and start the > server without problem, so the module itself should be in the proper path > for tyhe server to load. > > Any help on this will be apprieciated. > > Harry > GreatLodge.com -- Steve Piner Web Applications Developer Marketview Limited http://www.marketview.co.nz

Next Message by Date:

r->dir_config->(un)set issue...

Hi All, I have a situation where it is convinent for me to define a global "PerlSetVar" in my httpd.conf and then unset it for particular virtual hosts. I used to use the following configuration successfully: ---------------------------------------------------- httpd.conf ---------- <Perl> use Apache::Server; Apache->server->dir_config->unset("MyVar"); </Perl> ----------------------------------------------------- That stopped working for me ever since we compiled Apache/1.3.26 (Linix - Debian) with mod_perl/1.27 Has anyone else had the same issue? On a similar note: The following pices of code do not work: ----------------------------------------------------- code sample 1 -------------- 1. sub handler { 2. my $r = instance Apache::Request(shift); 3. 4. $r->dir_config(MyVar => undef); 5. 6. $r->dir_config->unset("MyVar"); 7. 8. $r->dir_config->set(MyVar => undef); 9. 10. } None of lines 4, 6 or 8 actually unset the variable. A collegue tells me that if a "true" value (for the key MyVar) is not passed to set then it ends up returning the value of MyVar - but then how i want to set the value of MyVar to be false. I would have though that unset/set would have specifically done what i told them to unset/set rather than do fancy things with truth values... Ideas anyone? simran.

Previous Message by Thread:

apache::ASP

Hello, I have got some problems when I tried to install Apache server together with mod_perl and Apache::ASP. After I had located four subfolder to c:/ , which mean, I have got c:/perl, c:/apache, c:/openssl, c:/readmes. When I tried to start apache.exe. There is an error message showing that it can't load c:/apache/modules/mod_perl.so. But I am sure I got all the files I need. Why is it like that? Thanks so much for your help. >From Jeremy. __________________________________________________ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com

Next Message by Thread:

[ANNOUNCE] Uttu 0.03

In preparation for some other work I'm doing, I have added some features and fixed some bugs in Uttu: o Added support for AxKit as a content handler. The handler allows using either HTML::Mason or Template Toolkit as an XML provider with a simple configuration setting. o Made the core code more robust by testing for certain conditions that can raise warnings in Perl. o Moved from multiple database specifications to multiple host specifications. Now, Uttu will go through a list of hosts looking for one that allows a connection to the database. There are still some features on the todo list, such as one-time urls, but this is enough for now. Released onto CPAN as Uttu-0.03.tar.gz and available at http://www.cpan.org/modules/by-authors/id/J/JS/JSMITH/Uttu-0.03.tar.gz http://sourceforge.net/projects/gestinanna/ Documentation and more information can be found http://uttu.tamu.edu/ . -- James Smith <JGSmith@xxxxxxxx>, 979-862-3725 Senior Software Applications Developer, Texas A&M CIS Operating Systems Group, Unix
blog comments powered by Disqus

Home | News | Sitemap | FAQ | advertise | OSDir is an Inevitable website. GBiz is too!