F5 iRule使用HTTPOnly和Secure安全Cookie但不包含cookie名称=" cnlfsid"

时间:2017-05-25 05:17:00

标签: cookies httponly f5 irule

我们需要使用HTTPOnly和Secure安全Cookie但不包含cookie名称=" cnlfsid"

这是我的代码:

when HTTP_RESPONSE { 
    foreach x [HTTP::cookie names] {

        set ckname $x
        set ckvalue [HTTP::cookie value $x]
        set ckpath [HTTP::cookie value path]

        if {!($ckname equals "cnlfsid")} {
            HTTP::cookie remove $x
            HTTP::cookie insert name $ckname value $ckvalue path $ckpath version 1
            HTTP::cookie secure $ckname enable
            HTTP::cookie httponly $ckname enable    
        }
    }
}

但它无法奏效。有人可以帮我修理它。

非常感谢

1 个答案:

答案 0 :(得分:0)

评论中提到的f5 forum的答案是:

when HTTP_RESPONSE {
    foreach x [HTTP::cookie names] {
        if { $x equals "cnlfsid" } {
            continue
        }
        set ckname $x
        set ckvalue [HTTP::cookie value $x] 
        set ckpath [HTTP::cookie $x path]
        HTTP::cookie remove $x
        HTTP::cookie insert name $ckname value $ckvalue path $ckpath version 1
        HTTP::cookie secure $ckname enable
        HTTP::cookie httponly $ckname enable
    }
}

看起来像诀窍是continue语句。