Forum Discussion
karthik_sriniva
Nimbostratus
Apr 07, 2005Setting HTTP COOkie
Hi,
I am trying to set a HTTP Cookie from AUTH_SUCCESS event and I get the following error
[command is not valid in current event context (AUTH_SUCCESS)] [HTTP::username]
...
karthik_sriniva
Nimbostratus
Apr 07, 2005
when CLIENT_ACCEPTED {
set tmm_auth_radius_sid [AUTH::start pam default_radius]
}
when HTTP_REQUEST {
set username {encrypt {[HTTP::username]}}
if { [HTTP::cookie exists "XYZ"] } {
use pool gtwLogin
HTTP::release
}
if { ![HTTP::cookie exists "XYZ"] } {
log "in auth block"
AUTH::username_credential $tmm_auth_radius_sid [HTTP::username]
AUTH::password_credential $tmm_auth_radius_sid [HTTP::password]
AUTH::authenticate $tmm_auth_radius_sid
if {$tmm_auth_radius_sid eq [AUTH::last_event_session_id]} {
log "abt to set auth hdr "
set newauth [b64encode [format "%s:%s" [HTTP::username] "xxxx"]]
HTTP::header insert Authorization "Basic $newauth"
}
HTTP::collect
}
}
when AUTH_SUCCESS {
if {$tmm_auth_radius_sid eq [AUTH::last_event_session_id]} {
log "called release after auth success"
[HTTP::cookie value "XYZ2" username]
HTTP::release
}
}
when AUTH_FAILURE {
if {$tmm_auth_radius_sid eq [AUTH::last_event_session_id]} {
HTTP::respond 401
}
}
when AUTH_WANTCREDENTIAL {
if {$tmm_auth_radius_sid eq [AUTH::last_event_session_id]} {
HTTP::respond 401
}
}
when AUTH_ERROR {
if {$tmm_auth_radius_sid eq [AUTH::last_event_session_id]} {
HTTP::respond 401
}
}
when HTTP_RESPONSE {
}
XYZ is the cookie that I have set as the name in the cookie persistence profile. This is not encrypted, so I would like to set another encrypted cookie (XYZ2) with username as its value. I do not know where to include the HTTP:cookie method so that the cookie will get set.
Thanks for your help,
Karthik
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