Forum Discussion
logging each cookie name failing in logs
The below code is throwing an error in the logs:
when HTTP_REQUEST {
set cookies [HTTP::cookie names]
foreach cookie $::cookies {
log local0. "Cookie: $::cookie"
}
}
Error in logs:
TCL error: qadpreviewdev.qad.com HTTP_RESPONSE - cant read ::cookies: no such variable while executing foreach cookie $::cookies { log local0. Cookie: $::cookie }
Any help if fully appreciated.
Thanks.
Regards,
TRX
- hooleylistCirrostratusHi TRX,
when HTTP_REQUEST { Loop through each cookie by name foreach cookie [HTTP::cookie names] { Log the cookie name and value log local0. "Cookie name: $cookie, Cookie value: [HTTP::cookie value $cookie]" } }
- Thanks Aaron. If I wanted to delete a cookie from the client machine would I do that in the request or the response function?
- hooleylistCirrostratusIf you want the client to remove the cookie, you'd need to set the cookie in a response with the expire date in the past:
when HTTP_RESPONSE { HTTP::cookie insert name "my_cookie_name" value "nada" path "/" HTTP::cookie expires "my_cookie_name" 0 absolute }
- Thanks. Let me try that.
- Aaron, do you know why this example is deleting the cookie in the HTTP_REQUEST function?
- hooleylistCirrostratusBecause there isn't a cookie rename function. So the cookie value is set with a new name and then the old cookie is removed.
- So when doing this in the HTTP_RESPONSE function:
- Had another question. Is the below statement true?
- Any thoughts on this?
- hooleylistCirrostratusshould I see the cookies on the client machine or ONLY the cookies that the server/web app is sending to the client machine?
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com