Forum Discussion
Jason_LaRocque_
Nimbostratus
Jan 26, 2007Checking if cookie exists on HTTP_RESPONSE
Good Morning-
We're looking to remove Apache servers from our DMZ in favor of other technologies (not apache based). However, we do unique user tracking with MOD_TRACKING in apache that inserts a SANE cookie. This cookie is used to identify uniqueness of visitors and track their usage of the site.
QUESTION:
I'm inserting a cookie on response that is a combination of source IP and current time in clock seconds. This part seems to work. The part that fails is the check to see if the cookie exists (naturally I don't want to insert the cookie if it exists in order to keep the original value).
Here's the rule:
when HTTP_RESPONSE {
set currtime [clock seconds]
set clientip [IP::client_addr]
set cookieval [concat $clientip-$currtime]
if {[HTTP::cookie exists "trackcookie"] == 1} {
}
elseif {[HTTP::cookie exists "trackcookie"] == 0} {
HTTP::cookie insert name "trackcookie" value $cookieval path / domain .mydomain.com
HTTP::cookie expires "trackcookie" 3000 relative
}
}
Any ideas?
Thanks everyone!!
Jason
- Leo_Katona_5507
Nimbostratus
If I understood correctly, you want to set the cookie if it isn't found in the request received from the user. What you're actually doing is checking whether it is present in the response being sent back from the server, which, of course, it never is.when HTTP_REQUEST { set isset [HTTP::cookie exists {trackcookie}] } when HTTP_RESPONSE { if {$isset == 0} { HTTP::cookie insert name {trackcookie} value "[IP::client_addr]-[clock seconds]" path {/} domain {.mydomain.com} HTTP::cookie expires {trackcookie} 3000 relative } }
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects