Forum Discussion
F5_Freek_243545
Nimbostratus
May 06, 2016How to configure cookie "secure; http-only;" ?
Hi Folks,
I want to make cookie secure and http only for an SSL url. I have wrote small irule to insert it in header. Does it make sense? Is there any problem we should expect if you are doing it in this way? I saw lot of big irules floating in Devcentral but bit confused now. Please help 🙂
when HTTP_RESPONSE {
HTTP::header replace Set-Cookie "[HTTP::header value Set-Cookie];HttpOnly;Secure"
}
-Freeky
1 Reply
Hello,
You can set the secure flag by using the following lines of codes (within HTTP_RESPONSE event) :
set myValues [HTTP::cookie names] foreach mycookies $myValues { HTTP::cookie secure $mycookies enable set value [HTTP::cookie value $mycookies] set testvalue [string tolower $value] set valuelen [string length $value] switch -glob $testvalue { "*;httponly*" - "*; httponly*" { } default { set value "$value; HttpOnly"; } } if { [string length $value] > $valuelen} { HTTP::cookie value $mycookies "${value}" } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
