Adding httponyle and secure attributes a ustom cookie persistence profile

Hi,

Customer was asking if it would be possible to add httponly and secure attributes to their Virtual Server specific cookie based persistence profile for example i have cookie profile for customer1 and there is cookie name customer_cookie.

How could I add those attributes to the customer_cookie with an iRule.

Thanks in advance

Teemu

Hi Kai,

Thanks for reply but I can’t find those options. We use 11.6.0. What version are you running ?

Any idea to make that same outcome with an iRule?

Thanks,

Teemu

Hi Teemu,

you’re right, the build in support for HttpOnly and Secure flags is somewhat new (v12+ feature). To have the same functionality for older versions, you may want to use the iRule below…

when HTTP_RESPONSE {
    foreach cookie [HTTP::cookie names] {
        if { $cookie starts_with "BIGipServer" } {
            HTTP::cookie version $cookie 1
            HTTP::cookie secure $cookie enable
            HTTP::cookie httponly $cookie enable
        }
    }
}

Note: You have to change theline, if you’re using a non-default cookie name.

$cookie starts_with "BIGipServer"

Cheers, Kai

Hi Kai and thanks again !

One more thing about this. Should I apply this only to HTTPS VS if we use HTTP to HTTPS redirect iRule in the HTTP VS ?

Thanks in advance for your big help! :slight_smile:

Teemu

Hi Teemu, you’re welcome! :wink: If you’re going to redirect everything from HTTP to HTTPS, then you don’t need to use a default pool, persistence profile and cookie rewrite iRule for the HTTP Virutal Server. Cheers, Kai