Re: CGI::Cookie vs Apache::Cookie -- help?

2001-06-18 Thread will trillich

On Mon, Jun 18, 2001 at 07:18:56AM +0200, Per Einar wrote:
> 
> - Original Message -
> From: "will trillich" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, June 18, 2001 7:09 AM
> Subject: Re: CGI::Cookie vs Apache::Cookie -- help?

> > what does $cookie->bake do (add set-cookie header) that
> > $r->header_out('set-cookie'=>$cookie) (add set-cookie header)
> > does not?
> >
> > [ and why ain't that mentioned in the manual? ]
> 
> As someone else stated, bake() actually sends a Set-Cookie header, but with
> $cookie->as_string and not just $cookie (which is an instance of
> Apache::Cookie). When you're just sending $cookie you're sending an object
> reference.
> 
> Per Einar Ellefsen
> [EMAIL PROTECTED]

my grok quotient has grown considerably. thanks!

-- 
I figure: if a man's gonna gamble, may as well do it
without plowing.   -- Bama Dillert, "Some Came Running"

[EMAIL PROTECTED]
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!



Re: CGI::Cookie vs Apache::Cookie -- help?

2001-06-17 Thread Per Einar


- Original Message -
From: "will trillich" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 18, 2001 7:09 AM
Subject: Re: CGI::Cookie vs Apache::Cookie -- help?


> On Sun, Jun 17, 2001 at 11:14:23PM -0400, Chris Winters wrote:
> > * will trillich ([EMAIL PROTECTED]) [010617 23:04]:
> > > $r->log_error( qq(...id=$ID, sending cookie) );
>
> --this outputs the string i'm hoping for, into the log file.

That's because you're outputting $ID and not the cookie itself, which you're
creating below.

>
> > > my $cookie =
> > > Apache::Cookie->new( $r,
> > > -name   => $cookie_name,
> > > -value  => $ID ,
> > > -domain => $r->hostname,
> > > -path   => '/' ,
> > > );
> > > $r->header_out('Set-Cookie', => $cookie);
>
> > From 'perldoc Apache::Cookie'
> >
> >bake
> >Put cookie in the oven to bake.  (Add a Set-Cookie
> >header to the outgoing headers table.)
> >
> >$cookie->bake;
>
> what does $cookie->bake do (add set-cookie header) that
> $r->header_out('set-cookie'=>$cookie) (add set-cookie header)
> does not?
>
> [ and why ain't that mentioned in the manual? ]

As someone else stated, bake() actually sends a Set-Cookie header, but with
$cookie->as_string and not just $cookie (which is an instance of
Apache::Cookie). When you're just sending $cookie you're sending an object
reference.

Per Einar Ellefsen
[EMAIL PROTECTED]




Re: CGI::Cookie vs Apache::Cookie -- help?

2001-06-17 Thread will trillich

On Sun, Jun 17, 2001 at 11:14:23PM -0400, Chris Winters wrote:
> * will trillich ([EMAIL PROTECTED]) [010617 23:04]:
> > $r->log_error( qq(...id=$ID, sending cookie) );

--this outputs the string i'm hoping for, into the log file.

> > my $cookie =
> > Apache::Cookie->new( $r,
> > -name   => $cookie_name,
> > -value  => $ID ,
> > -domain => $r->hostname,
> > -path   => '/' ,
> > );
> > $r->header_out('Set-Cookie', => $cookie);

> From 'perldoc Apache::Cookie'
> 
>bake
>Put cookie in the oven to bake.  (Add a Set-Cookie
>header to the outgoing headers table.)
> 
>$cookie->bake;

what does $cookie->bake do (add set-cookie header) that
$r->header_out('set-cookie'=>$cookie) (add set-cookie header)
does not?

[ and why ain't that mentioned in the manual? ]

-- 
I figure: if a man's gonna gamble, may as well do it
without plowing.   -- Bama Dillert, "Some Came Running"

[EMAIL PROTECTED]
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!



Re: CGI::Cookie vs Apache::Cookie -- help?

2001-06-17 Thread Cees Hek

On Sun, 17 Jun 2001, will trillich wrote:

>   $r->log_error( qq(...id=$ID, sending cookie) );
>   my $cookie =
>   Apache::Cookie->new( $r,
>   -name   => $cookie_name,
>   -value  => $ID ,
>   -domain => $r->hostname,
>   -path   => '/' ,
>   );
>   $r->header_out('Set-Cookie', => $cookie);

You forgot to bake your cookie...  Read the Apache::Cookie docs again.

Get rid of the $r->header_out(...) line and use the following instead.

$cookie->bake();

Cees




Re: CGI::Cookie vs Apache::Cookie -- help?

2001-06-17 Thread Chris Winters

* will trillich ([EMAIL PROTECTED]) [010617 23:04]:
> mine is similar:
> 
>   $r->log_error( qq(...id=$ID, sending cookie) );
>   my $cookie =
>   Apache::Cookie->new( $r,
>   -name   => $cookie_name,
>   -value  => $ID ,
>   -domain => $r->hostname,
>   -path   => '/' ,
>   );
>   $r->header_out('Set-Cookie', => $cookie);
> 
> which sets a cookie value of "SCALAR(0x863c9f8)" instead of the
> $ID string that shows up in the log, which is
> 
>   ...id=483dd0e2202accce6d4d3e07d976bfdc, sending cookie
> 
> in the original ticket example above, -value is a hashref:
> 
>   -value => { ID => $ID }
> 
> instead of
> 
>   -value => $ID
> 
> as the Apache::Cookie manpage suggests (a plain scalar value).
> 
> this worked just fine with CGI::Cookie (without the $r, of
> course) -- can't get it to return the actual scalar value with
> Apache::Cookie...
> 
> ideas? help!

>From 'perldoc Apache::Cookie'

   bake
   Put cookie in the oven to bake.  (Add a Set-Cookie
   header to the outgoing headers table.)

   $cookie->bake;

   as_string
   Format the cookie object as a string:

   #same as $cookie->bake
   $r->err_headers_out->add("Set-Cookie" => $cookie->as_string);


HTH

Chris

-- 
Chris Winters ([EMAIL PROTECTED])
Building enterprise-capable snack solutions since 1988.