Does anyone know how I could log into Apache access_logs a cookie that I've just set in the response ? A basic scenario would be :

  1. A user comes to my site with a bunch of already existing cookies for this domain
  2. My PHP web application sets a new cookie (let's call it "foo" with value "bar")
  3. I want to log this cookie into Apache using a CustomLogFormat

I've looked at Apache Documentation for mod_log_config but it is explicitly said that {foo}C will log the cookie named "foo" found in the request and not in the response.

I've maybe found a solution with a RewriteRule and a RewriteCond but it does not seem to be a good idea : not a clean code :(

Another method would be to store the cookie value in an Apache env using PHP apache_setenv() method and use it in CustomLog with {FOO}e. It feels to me that it would be cleaner that the first solution but I'm still not satisfied.

Do you have any idea how I could log a cookie set in the response header ? Thanks !

link|improve this question
feedback

migrated from webmasters.stackexchange.com Oct 1 '11 at 4:17

This question came from our site for pro webmasters.

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown