l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
October 7: Social gathering
Next Installfest:
TBD
Latest News:
Aug. 18: Discounts to "Velocity" in NY; come to tonight's "Photography" talk
Page last updated:
2003 May 22 16:02

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[vox-tech] Trying to use Apache::Cookie
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vox-tech] Trying to use Apache::Cookie



Ok, since it seems mod_perl is an appropriate topic.  Here a mod_perl
question.

I'm trying to use Apache::Cookie.  But I'm unable to send the cookie.  I can
pick it up fine using Apache::Cookie->fetch (if I send it using
CGI::Cookie). I must not be doing something, like sending the header, or I'm
doing something else wrong.  Below are 2 pieces of code the first is
supposed to create a cookie, the second fetches it and displays the keys.

Thanks
Jay

package Apache::Init;

use strict;
use Apache::Constants qw(:common);
use Apache::Cookie;
use CGI::Cookie;
use CGI qw/:standard/;

sub handler {
   my $r = shift;

#  If I do it like this it works
#
 #my $cookie1 = new CGI::Cookie(-name=>'ID',-value=>123456);
#my $cookie2 = new CGI::Cookie(-name=>'preferences',
#                            -value=>{ font => 'Helvetica',
#                                      size => 12 }
#                            );
#print header(-cookie=>[$cookie1,$cookie2]);

   my $cookie = Apache::Cookie->new($r,
                             -name    =>  'foo',
                             -value   =>  'bar',
                             -expires =>  '+3M',
                             -domain  =>  '.heyjay.com',
                             -secure  =>  1
                            );

   $cookie->bake;

   return OK;

}


1;


Second Code
===========
package Apache::Catch;

use strict;
use Apache::Constants qw(:common);
use CGI '-autoload';
use Apache::Cookie;
use CGI::Cookie;

sub handler {
   my $r = shift;
   my %cookies = Apache::Cookie->fetch;

   map{$r->log_error($_); print "$_\n"} keys %cookies;
   return OK;

}

1;

__END__



_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.