Forum Discussion
Problem to create a cookie session
I suspect you're looking on the client for the cookie, but your cookie insertion code is being set in the HTTP request, so the cookie is getting sent to the server. If you want the cookie at the client, you have a few options depending on how you want the traffic to flow.
If you want the server to respond to the "?LastAuthFailed" URI (option 1), then you would set a flag in the HTTP_REQUEST event and set the cookie in the HTTP_RESPONSE event.
If you want the BIG-IP to handle the "?LastAuthFailed" URI (option 2), (ie. a redirect or some arbitrary code), then you can set the cookie in the HTTP_REQUEST event using the HTTP::respond command.
# Option 1
when HTTP_REQUEST {
if { [HTTP::uri] ends_with "?LastAuthFailed=1" } {
set setcookie 1
}
}
when HTTP_RESPONSE {
if { [info exists setcookie] } {
unset setcookie
HTTP::cookie insert name "MyCookie" value "toto"
HTTP::cookie path "MyCookie" "/"
}
}
# Option 2
when HTTP_REQUEST {
if { [HTTP::uri] ends_with "?LastAuthFailed=1" } {
HTTP::respond 200 content "..." "Set-Cookie" "MyCookie=toto; path=/"
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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