Jump to content
Welcome to our new Citrix community!

Need to KNow how to build Cookie-Insert expression through Expression

Recommended Posts

I need help regarding who to build/insert cookie through netscaler expressions .

I have come across one such requirement where simply inserting using cookie-insert is not helping .


I have one expression which is being used in F5 so i want to know if any expression which we can use here to perform the same function .


Here is the expression of F5 :


## This section allows the F5 to send to the back-end
## application the exact same cookie name and value the 
## F5 will be creating for the client. This allows the 
## application to have the information even on the initial
## request 
    #following 3 lines could determine persistence cookie name being used if not manually set in the previous line
    #if {not [info exists cookie_name]} {
    #    if { [set cookie_name [PROFILE::persist mode cookie cookie_name]] eq "" } { set cookie_name "BIGIPServer"[getfield [LB::server pool] "/" 3] }
    #Next function is here to forge the persistence cookie value when it doesn't exist yet (because it's the first hit)
    if { [set COOKIE [HTTP::cookie value $cookie_name]] == "" } {
        scan [LB::server addr] {%d.%d.%d.%d} a b c d
        #Forging the cookie value based on sol6917
        set ADDR [expr { $a + $b * 256 + $c * 65536 + $d * 16777216 }]
        set PORT [ntohs [LB::server port]]
        set COOKIE "${ADDR}.${PORT}.0000"
        #log local0. "$cookie_name = $COOKIE created for [HTTP::uri]"
        unset a b c d ADDR PORT
    HTTP::header insert "X-dsp-client-node" $COOKIE

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...