You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Allasso Travesser <al...@gmail.com> on 2013/12/11 19:27:31 UTC

[users@httpd] cookie read/write in module handler

Hello,

I am attempting to write a cookie, then retrieve it later.  I am doing this in a handler, using simple code found from (sparse) information I have gathered from google searches:

  apr_table_set(r->headers_out, "Set-Cookie", "value");
  char* cookie = apr_table_get(r->headers_in, "Set-Cookie");

  ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL, “cookie : %s", cookie);

I would expect that after the having a particular browser access the site twice, the second time the cookie should show up, but such is not that case, instead, no matter how many times I access, value read into “cookie” variable is always “NULL”.

Am I being naive about how to implement this?  Or does this method not work in a handler?

Thank you kindly,

Allasso


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] cookie read/write in module handler

Posted by Allasso Travesser <al...@gmail.com>.
Easy fix, my “cookie” wasn’t in the proper format.

“cookiename=value” works.

It as sending them, but the browser (Safari) wasn’t sending them back.  (Firefox actually did send it back though, even without the proper format)

Thanks.

Allasso


On Dec 11, 2013, at 12:09 PM, Rainer M. Canavan <ra...@sevenval.com> wrote:

> 
> On Dec 11, 2013, at 19:53 , Allasso Travesser <al...@gmail.com> wrote:
> 
>>>> I am attempting to write a cookie, then retrieve it later.  I am doing this in a handler, using simple code found from (sparse) information I have gathered from google searches:
>>>> 
>>>> apr_table_set(r->headers_out, "Set-Cookie", "value");
>>>> char* cookie = apr_table_get(r->headers_in, "Set-Cookie");
>>> 
>>> When it comes back, it's a "Cookie" not a "Set-Cookie”.
>> 
>> thanks, that makes sense — unfortunately it didn’t work…  :-(
> 
> 
> If you haven't done so already, use a custom LogFormat to log the outgoing
> Set-Cookie and the incoming Cookie Headers, and/or use your favourite web 
> developer tools to check if the header is set (and sent back). You could also 
> either run httpd -X from within gdb or attach gdb to a running process and set 
> a breakpoint at your apr_table_… lines. You should then be able to inspect r. 
> You might  find the .gdbinit that comes with the apache source code helpful.
> 
> rainer
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] cookie read/write in module handler

Posted by "Rainer M. Canavan" <ra...@sevenval.com>.
On Dec 11, 2013, at 19:53 , Allasso Travesser <al...@gmail.com> wrote:

>>> I am attempting to write a cookie, then retrieve it later.  I am doing this in a handler, using simple code found from (sparse) information I have gathered from google searches:
>>> 
>>> apr_table_set(r->headers_out, "Set-Cookie", "value");
>>> char* cookie = apr_table_get(r->headers_in, "Set-Cookie");
>> 
>> When it comes back, it's a "Cookie" not a "Set-Cookie”.
> 
> thanks, that makes sense — unfortunately it didn’t work…  :-(


If you haven't done so already, use a custom LogFormat to log the outgoing
Set-Cookie and the incoming Cookie Headers, and/or use your favourite web 
developer tools to check if the header is set (and sent back). You could also 
either run httpd -X from within gdb or attach gdb to a running process and set 
a breakpoint at your apr_table_… lines. You should then be able to inspect r. 
You might  find the .gdbinit that comes with the apache source code helpful.

rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] cookie read/write in module handler

Posted by Allasso Travesser <al...@gmail.com>.
On Dec 11, 2013, at 11:31 AM, Eric Covener <co...@gmail.com> wrote:

> On Wed, Dec 11, 2013 at 1:27 PM, Allasso Travesser
> <al...@gmail.com> wrote:
>> Hello,
>> 
>> I am attempting to write a cookie, then retrieve it later.  I am doing this in a handler, using simple code found from (sparse) information I have gathered from google searches:
>> 
>>  apr_table_set(r->headers_out, "Set-Cookie", "value");
>>  char* cookie = apr_table_get(r->headers_in, "Set-Cookie");
> 
> When it comes back, it's a "Cookie" not a "Set-Cookie”.

thanks, that makes sense — unfortunately it didn’t work…  :-(



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] cookie read/write in module handler

Posted by Eric Covener <co...@gmail.com>.
On Wed, Dec 11, 2013 at 1:27 PM, Allasso Travesser
<al...@gmail.com> wrote:
> Hello,
>
> I am attempting to write a cookie, then retrieve it later.  I am doing this in a handler, using simple code found from (sparse) information I have gathered from google searches:
>
>   apr_table_set(r->headers_out, "Set-Cookie", "value");
>   char* cookie = apr_table_get(r->headers_in, "Set-Cookie");

When it comes back, it's a "Cookie" not a "Set-Cookie".

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org