> > <Location /images/header_top_left.gif>
> >     PerlFixupHandler Cookieme
> > </Location>
> > 
> > And here's teh entire Cookieme module:
> 
> i dropped your code in mod_perl-1.xx/t/docs/startup.pl
> and config in t/conf/httpd.conf (in the /perl/perl-status Location), it
> works just fine.  your cookie format looks wrong though, maybe netscape
> can't parse it?

That's probably because I copied the example verbatim. I
still seem to be having problems. I've re-written my 
handler using the Apache Request object and Apache::Cookie
and still it doesn't seem to work. Basically, what I'm trying
to accomplish is the following:

1.) Visitor comes to site
2.) Handler checks for presence of a sessionID cookie.
3a) If cookie DOESN'T exist, then it creates a cookie and sends it.
3b) ...otherwise, do nothing.

My problem is that it seems when I go to retrieve the cookie
in the Fixup phase, that the cookie isn't available and it's
set each time. Here's my handler, tested in both IE and
Netscape:

-----
package TradiantNet::Cookie;

require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(handler);

use strict;
use Tradiant::Utilities;

sub handler {
  
    my $r = shift;

    # Initialize CGI object
    my $query = init_cgi();

    # If the user doesn't have a cookie, let's send them one
    unless (defined($temp)) {
        # Have Apache generate a unique ID.
        my $uniqueID = $r->subprocess_env->{'UNIQUE_ID'};

        # Create the cookie
        my $cookie = $query->cookie(    -name   => 'sessionID',
                                        -value  => $uniqueID,
                                        -expires=> '+3y',
                                        -path   => '/',
                                        -domain => '.tradiant.com');

        # Send them the cookie
        print $query->header(-cookie=>$cookie);
    }

}

1;
-----

Is there an easier way to accomplish this? I seem to recall
that Apache has a simplfied way of setting a cookie upon the
initial request if one wasn't yet set, but I can't find anything
in the docs.

Jim

Reply via email to