Forum Discussion
Trigger Once per session for specific client iRule
Good evening all,
I am looking for a way to do a "one time" trigger within an iRule.
Scenario:
User accesses site and if the html text "banana" is seen, log something, insert something do something but just once for this session. If someone could point me in the direction on how to set a constant variable that lasts for the duration of the session, I think that would work.
Thanks!
7 Replies
- IheartF5_45022
Nacreous
All variables have scope of TCP session. Or do you mean users browser session? You could add in a session cookie to help you with that.
Also when you say 'html text "banana"' do you mean if you see the word 'banana' in the content of an HTTP response?
A bit more info and we can give you some code to illustrate.....
- IheartF5_45022
Nacreous
Create a stream profile str_banana that looks for string 'banana', then attach an iRule as follows;-
when STREAM_MATCHED { if {![HTTP::cookie exists 'banana']} { Insert session cookie HTTP::cookie insert name 'banana' value "1" HTTP::cookie httponly 'banana' enable log local0. "Banana seen for this session" } STREAM::disable } - jspiglerj2rsolves
Nimbostratus
Sorry if my requirements weren't clear. My use case wasn't the greatest. I'm simply trying to track within the Big-IP when a specific criteria is met, carry out action X and don't do it again for the duration of the users session. Unfortunately setting a cookie on the clients end is not an option. Doing further research, would setting the value in the session table work?
Something like this
when HTTP_REQUEST {
if { [table -subtable lookup [IP::client_addr] [HTTP::host]] !=""} { return }elseif { ([HTTP::header value host] contains "web.company.com")} { log local0. "Criteria met for [IP::client_addr] for [HTTP::header value host] in request" table set -subtable [IP::client_addr] [HTTP::host] }}
when CLIENT_CLOSED {
table delete -subtable [IP::client_addr]
}
- jspiglerj2rsolves
Nimbostratus
I don't think my syntax is correct though...
- IheartF5_45022
Nacreous
Do you mean browser session or TCP connection? If the latter then very easy as all variables are scoped for TCP session;-
when STREAM_MATCHED { if {![info exists fBananaSeen]} { Set variable set BananaSeen 1 log local0. "Banana seen for this TCP connection" } STREAM::disable }No need to delete anything when connection closes as variable automatically cleared.
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