Forum Discussion
Rusty_Hale_8009
Nimbostratus
Apr 26, 2005Grab cookie contents and insert it as another.
I want to grab the contents of a cookie (from an http post) and insert that value into a new cookie with a different name. This is what I have so far that will not pass syntax:
when HTTP_REQUEST {
set auth_user [findstr [HTTP::cookie txtUsername] "txtUsername" 12 "&" ]
HTTP::cookie insert auth_user $auth_user
log "User ID being passed to Iplanet $auth_user"
}
Note: txtUsername is the original cookie name and auth_user is the new cookie that I want to insert that value in.
Can someone help me? I feel like I am really close. I guess I could get that information from the cookie instead of doing a findstr???
We are trying to pass a user ID to the web logs and Iplanet is stripping the original cookie. Thanks in advance for all the help. Devcentral is the best.
8 Replies
- The usage for HTTP::cookie insert is the following:
HTTP::cookie insert name auth_user value $auth_user
- Rusty_Hale_8009
Nimbostratus
Joe, It passed syntax but when I try to display the value in the logs, it is always empty. I can see that value in the tcpdump which shows: - I would start by first logging the value of the cookie itself
set cookie_value [HTTP::cookie txtUsername] log "txtUserName Value: $cookie_value"
- Rusty_Hale_8009
Nimbostratus
Joe, It appears that the information I am trying to get is in the payload. I tried to get cookie and header and neither one work. It has to be in the payload. I am pasting the output of the tcpdump where I captured the transaction. You will see a line right after the Cookie: SMIDENTITY= and it starts with txtUsernameView= What I am trying to get is the second value which is txtUsername=00556987 and store the part after the = in a cookie. I have tried everything I know to try to capture this information. I am hoping you can help me out. Thanks. - Looks like you've got your contents in the POST data which is indeed part of the HTTP payload. Here's some code to collect the full POST data via the Content-Length header and then it uses findstr to search in the payload data for the txtUsername= string.
when HTTP_REQUEST { set clen [HTTP::header Content-Length] HTTP::collect $clen } when HTTP_REQUEST_DATA { set authuser [findstr [HTTP::payload $clen] "txtUsername=" 12 "&"] log "txtUserName Value: $authuser" }
- Rusty_Hale_8009
Nimbostratus
Joe, We are getting close but I got this error when I put the rule in the Big IP. - Looks like this may be catching on another non-POST request. Give this a try
when HTTP_REQUEST { if { [HTTP::header exists "Content-Length"] } { set clen [HTTP::header Content-Length] log "found Content-Length: $clen" if { $clen > 0 } { HTTP::collect $clen } } } when HTTP_REQUEST_DATA { set authuser [findstr [HTTP::payload] "txtUsername=" 12 "&"] log "txtUserName Value: $authuser" }
- Anytime! Keep us updated with what you are working on...
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