> 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.
I'm doing something vaguely similar.
========================================
sub handler {
my($r,$cookie);
$r = shift; # the request object
if ($cookie = $r->header_in('Cookie')
and $cookie =~ /somevalue/o) {
# ... got the cookie, do some code....
} else { # no cookie, so set one
my $val = 'something useful';
$r->headers_out->add('Set-Cookie' =>
"name=$val; path=/;");
}
# ... return something useful
}
===================================================================
$r->header_in('Cookie') reads the HTTP headers the browser sent with
the request, which include Cookies.
$r->headers_out->add('Set-Cookie' => "CUID=$usr; path=/;") adds a
Set-Cookie header to the HTTP header lines going out with the response.
I do have a question, though. Don't seperate cookies coming in from
the browser get seperate Cookie: headers? This code is working, but I
don't want to build it to break later. Should I be reading them into
an array?
Also, as I mentioned earlier, I couldn't get "domain=...;" to work.
Suggestions?
Anyway, hope that helps.
Feel free to offer criticisms and suggestions.
Paul
====
Notice on grape nuts box tab (in its entirety):
"CONTENTS MAY HAVE OCCURRED DURING SHIPPING AND HANDLING"
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/