Forum Discussion
Brent_Sachnoff_
Nimbostratus
Dec 06, 2007Assigning cookies only once
I'm trying to assign a client a cookie that will be psuedo random using:
when HTTP_RESPONSE {
expr srand([clock clicks])
set tracker [expr (rand() * 999) + 10]
HTTP::cooki...
hoolio
Cirrostratus
Dec 06, 2007You can use a local variable to track whether the cookie was presented in the client request:
when HTTP_REQUEST {
if {[HTTP::cookie exists tracker]}{
set need_cookie 0
log local0. "tracker cookie=[HTTP::cookie value tracker]"
} else {
set need_cookie 1
}
}
when HTTP_RESPONSE {
if {$need_cookie] }{
expr srand([clock clicks])
set tracker [expr (rand() * 999) + 10]
HTTP::cookie insert name tracker value $tracker path "/"
}
}
Aaron
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