Forum Discussion

Kevin_50491's avatar
Kevin_50491
Icon for Nimbostratus rankNimbostratus
Mar 04, 2013

Removal of specific cookie

I am looking for a method in which I could delete a designated cookie that has a specific name AND path. Normally deleting a cookie isn't an issue, but I am looking at a situation where I can have 2 or more cookies with the exact same name, and by default "cookie remove " deletes the oldest cookie that has the given name, with no other designated option for deletion that I know of.

 

I simply can't even come up with any sort of solution to even interact with any cookie with the shared names, except for the oldest. For example, even my attempt at iterating through all cookies (with will verify multiple cookies sharing the path, as does the count method) simply ends up accessing the oldest (the one with the root "/" path) multiple times:

 

 

HTTP::cookie insert name "abc1" value "testcookievalue1"

 

HTTP::cookie insert name "abc1" value "testcookievalue2" path "/DefinitelyAPath"

 

foreach aCookie [HTTP::cookie names] {

 

log local0. [HTTP::cookie path $aCookie]

 

}

 

Does anyone have a psosible alternative solution for this conundrum?

 

3 Replies

  • e.g.

    [root@ve10:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.252:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve10:Active] config  b pool foo list
    pool foo {
       members 200.200.200.101:80 {}
    }
    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when HTTP_RESPONSE {
      set ck_list [HTTP::header values "Set-Cookie"]
      HTTP::header remove "Set-Cookie"
      foreach ck $ck_list {
        if { not ($ck contains "Path=/DefinitelyAPath") } {
          HTTP::header insert "Set-Cookie" $ck
        }
      }
    }
    }
    
     accessing pool member directly
    
    [root@ve10:Active] config  curl -I http://200.200.200.101
    HTTP/1.1 200 OK
    Date: Tue, 05 Mar 2013 12:05:38 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Sat, 27 Oct 2012 03:22:35 GMT
    ETag: "4183f3-59-f28f94c0"
    Accept-Ranges: bytes
    Content-Length: 89
    Set-Cookie: abc1=testcookievalue1; Path=/
    Set-Cookie: abc1=testcookievalue2; Path=/DefinitelyAPath/; HttpOnly
    Set-Cookie: abc1=testcookievalue3; Path=/; HttpOnly
    Content-Type: text/html; charset=UTF-8
    
     accessing through virtual server (irule)
    
    [root@ve10:Active] config  curl -I http://172.28.19.252
    HTTP/1.1 200 OK
    Date: Tue, 05 Mar 2013 12:05:44 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Sat, 27 Oct 2012 03:22:35 GMT
    ETag: "4183f3-59-f28f94c0"
    Accept-Ranges: bytes
    Content-Length: 89
    Content-Type: text/html; charset=UTF-8
    Set-Cookie: abc1=testcookievalue1; Path=/
    Set-Cookie: abc1=testcookievalue3; Path=/; HttpOnly
    
    
  • Thank you very much for this! This does indeed solve the problem!

     

     

    Although, I must admit it does seem a little inefficient to have to remove every cookie and add back in all of them with the exception of the desired cookie for removal. Granted, I am not aware of any other methods of bypassing this issue, however.
  • Although, I must admit it does seem a little inefficient to have to remove every cookie and add back in all of them with the exception of the desired cookie for removal. Granted, I am not aware of any other methods of bypassing this issue, however.i agree. you are able to open a support case and submit request for enhancement (rfe) for the irule command.