Forum Discussion

daveg_20243's avatar
daveg_20243
Icon for Nimbostratus rankNimbostratus
Oct 19, 2011

Trouble removing cookie

Hi,

 

 

So I'm attempting to remove a cookie, nothing to fancy.

 

 

 

I've got this basic irule:

 

 

 

when HTTP_REQUEST {

 

HTTP::cookie remove "my-cookie"

 

}

 

 

 

That didn't work, so I put in another section:

 

 

 

when HTTP_RESPONSE {

 

HTTP::cookie remove "my-cookie"

 

}

 

 

 

No matter what, the cookie persists. What am I doing wrong?

 

4 Replies

  • e.g. request

    [root@iris:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.17.33:http
       ip protocol tcp
       profiles {
          http {}
          tcp {}
       }
    }
    [root@iris:Active] config  b pool foo list
    pool foo {
       members 10.10.70.110:http {}
    }
    
    New TCP connection 1: 192.168.206.102(61397) <-> 172.28.17.33(80)
    ---------------------------------------------------------------
    1319006186.8912 (0.0170)  C>S
    ---------------------------------------------------------------
    GET /dog.gif HTTP/1.1
    Host: 172.28.17.33
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.23) Gecko/20110920 Firefox/3.6.23
    Accept: image/png,image/*;q=0.8,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://172.28.17.33/
    Cookie: my-cookie=helloworld
    
    New TCP connection 2: 10.10.72.30(61397) <-> 10.10.70.110(80)
    ---------------------------------------------------------------
    1319006186.8913 (0.0172)  C>S
    ---------------------------------------------------------------
    GET /dog.gif HTTP/1.1
    Host: 172.28.17.33
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.23) Gecko/20110920 Firefox/3.6.23
    Accept: image/png,image/*;q=0.8,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://172.28.17.33/
    Cookie: my-cookie=helloworld
    
    
    [root@iris:Active] config  b virtual bar rule myrule
    [root@iris:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.17.33:http
       ip protocol tcp
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@iris:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
            HTTP::cookie remove "my-cookie"
    }
    }
    
    New TCP connection 1: 192.168.206.102(61539) <-> 172.28.17.33(80)
    ---------------------------------------------------------------
    1319006687.2403 (0.0396)  C>S
    ---------------------------------------------------------------
    GET /dog.gif HTTP/1.1
    Host: 172.28.17.33
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.23) Gecko/20110920 Firefox/3.6.23
    Accept: image/png,image/*;q=0.8,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://172.28.17.33/
    Cookie: my-cookie=helloworld
    
    New TCP connection 2: 10.10.72.30(61539) <-> 10.10.70.110(80)
    ---------------------------------------------------------------
    1319006687.2404 (0.0398)  C>S
    ---------------------------------------------------------------
    GET /dog.gif HTTP/1.1
    Host: 172.28.17.33
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.23) Gecko/20110920 Firefox/3.6.23
    Accept: image/png,image/*;q=0.8,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://172.28.17.33/
    
    
  • e.g. response

    [root@iris:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.17.33:http
       ip protocol tcp
       profiles {
          http {}
          tcp {}
       }
    }
    [root@iris:Active] config  b pool foo list
    pool foo {
       members 10.10.70.110:http {}
    }
    
    New TCP connection 2: 10.10.72.30(61675) <-> 10.10.70.110(80)
    ---------------------------------------------------------------
    1319007596.8976 (0.0060)  S>C
    ---------------------------------------------------------------
    48 54 54 50 2f 31 2e 31 20 32 30 30 20 4f 4b 0d    HTTP/1.1 200 OK.
    0a 44 61 74 65 3a 20 54 75 65 2c 20 31 38 20 4f    .Date: Tue, 18 O
    63 74 20 32 30 31 31 20 32 32 3a 31 33 3a 32 37    ct 2011 22:13:27
    20 47 4d 54 0d 0a 53 65 72 76 65 72 3a 20 41 70     GMT..Server: Ap
    61 63 68 65 2f 32 2e 30 2e 35 39 20 28 72 50 61    ache/2.0.59 (rPa
    74 68 29 0d 0a 4c 61 73 74 2d 4d 6f 64 69 66 69    th)..Last-Modifi
    65 64 3a 20 53 61 74 2c 20 31 31 20 4a 75 6e 20    ed: Sat, 11 Jun
    32 30 31 31 20 30 30 3a 33 31 3a 34 37 20 47 4d    2011 00:31:47 GM
    54 0d 0a 45 54 61 67 3a 20 22 36 36 37 61 2d 36    T..ETag: "667a-6
    37 2d 63 66 62 36 38 32 63 30 22 0d 0a 41 63 63    7-cfb682c0"..Acc
    65 70 74 2d 52 61 6e 67 65 73 3a 20 62 79 74 65    ept-Ranges: byte
    73 0d 0a 56 61 72 79 3a 20 41 63 63 65 70 74 2d    s..Vary: Accept-
    45 6e 63 6f 64 69 6e 67 0d 0a 43 6f 6e 74 65 6e    Encoding..Conten
    74 2d 45 6e 63 6f 64 69 6e 67 3a 20 67 7a 69 70    t-Encoding: gzip
    0d 0a 53 65 74 2d 43 6f 6f 6b 69 65 3a 20 6d 79    ..Set-Cookie: my
    2d 63 6f 6f 6b 69 65 3d 68 65 6c 6c 6f 77 6f 72    -cookie=hellowor
    6c 64 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67    ld..Content-Leng
    74 68 3a 20 39 36 0d 0a 4b 65 65 70 2d 41 6c 69    th: 96..Keep-Ali
    76 65 3a 20 74 69 6d 65 6f 75 74 3d 33 30 30 2c    ve: timeout=300,
    20 6d 61 78 3d 31 30 30 0d 0a 43 6f 6e 6e 65 63     max=100..Connec
    74 69 6f 6e 3a 20 4b 65 65 70 2d 41 6c 69 76 65    tion: Keep-Alive
    0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20    ..Content-Type:
    74 65 78 74 2f 68 74 6d 6c 3b 20 63 68 61 72 73    text/html; chars
    65 74 3d 55 54 46 2d 38 0d 0a 0d 0a 1f 8b 08 00    et=UTF-8........
    00 00 00 00 00 03 b3 c9 28 c9 cd b1 e3 b2 49 ca    ........(.....I.
    4f a9 04 52 19 86 76 e1 ae 3e ce fe be ae 8a 40    O..R..v..>.....@
    60 a3 0f e4 83 05 43 32 32 8b d5 8b 15 0c 0d f4    `.....C22.......
    80 c8 1c 48 02 29 a8 6c 66 6e ba 42 71 51 b2 ad    ...H.).lfn.BqQ..
    52 4a 7e ba 5e 7a 66 9a 92 82 3e 50 54 1f 6a a0    RJ~.^zf...>PT.j.
    3e c4 7c 00 fc 6a 57 13 67 00 00 00                >.|..jW.g...
    
    New TCP connection 1: 192.168.206.102(61675) <-> 172.28.17.33(80)
    ---------------------------------------------------------------
    1319007596.8976 (0.0065)  S>C
    ---------------------------------------------------------------
    48 54 54 50 2f 31 2e 31 20 32 30 30 20 4f 4b 0d    HTTP/1.1 200 OK.
    0a 44 61 74 65 3a 20 54 75 65 2c 20 31 38 20 4f    .Date: Tue, 18 O
    63 74 20 32 30 31 31 20 32 32 3a 31 33 3a 32 37    ct 2011 22:13:27
    20 47 4d 54 0d 0a 53 65 72 76 65 72 3a 20 41 70     GMT..Server: Ap
    61 63 68 65 2f 32 2e 30 2e 35 39 20 28 72 50 61    ache/2.0.59 (rPa
    74 68 29 0d 0a 4c 61 73 74 2d 4d 6f 64 69 66 69    th)..Last-Modifi
    65 64 3a 20 53 61 74 2c 20 31 31 20 4a 75 6e 20    ed: Sat, 11 Jun
    32 30 31 31 20 30 30 3a 33 31 3a 34 37 20 47 4d    2011 00:31:47 GM
    54 0d 0a 45 54 61 67 3a 20 22 36 36 37 61 2d 36    T..ETag: "667a-6
    37 2d 63 66 62 36 38 32 63 30 22 0d 0a 41 63 63    7-cfb682c0"..Acc
    65 70 74 2d 52 61 6e 67 65 73 3a 20 62 79 74 65    ept-Ranges: byte
    73 0d 0a 56 61 72 79 3a 20 41 63 63 65 70 74 2d    s..Vary: Accept-
    45 6e 63 6f 64 69 6e 67 0d 0a 43 6f 6e 74 65 6e    Encoding..Conten
    74 2d 45 6e 63 6f 64 69 6e 67 3a 20 67 7a 69 70    t-Encoding: gzip
    0d 0a 53 65 74 2d 43 6f 6f 6b 69 65 3a 20 6d 79    ..Set-Cookie: my
    2d 63 6f 6f 6b 69 65 3d 68 65 6c 6c 6f 77 6f 72    -cookie=hellowor
    6c 64 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67    ld..Content-Leng
    74 68 3a 20 39 36 0d 0a 4b 65 65 70 2d 41 6c 69    th: 96..Keep-Ali
    76 65 3a 20 74 69 6d 65 6f 75 74 3d 33 30 30 2c    ve: timeout=300,
    20 6d 61 78 3d 31 30 30 0d 0a 43 6f 6e 6e 65 63     max=100..Connec
    74 69 6f 6e 3a 20 4b 65 65 70 2d 41 6c 69 76 65    tion: Keep-Alive
    0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20    ..Content-Type:
    74 65 78 74 2f 68 74 6d 6c 3b 20 63 68 61 72 73    text/html; chars
    65 74 3d 55 54 46 2d 38 0d 0a 0d 0a 1f 8b 08 00    et=UTF-8........
    00 00 00 00 00 03 b3 c9 28 c9 cd b1 e3 b2 49 ca    ........(.....I.
    4f a9 04 52 19 86 76 e1 ae 3e ce fe be ae 8a 40    O..R..v..>.....@
    60 a3 0f e4 83 05 43 32 32 8b d5 8b 15 0c 0d f4    `.....C22.......
    80 c8 1c 48 02 29 a8 6c 66 6e ba 42 71 51 b2 ad    ...H.).lfn.BqQ..
    52 4a 7e ba 5e 7a 66 9a 92 82 3e 50 54 1f 6a a0    RJ~.^zf...>PT.j.
    3e c4 7c 00 fc 6a 57 13 67 00 00 00                >.|..jW.g...
    
    
    [root@iris:Active] config  b virtual bar rule myrule
    [root@iris:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.17.33:http
       ip protocol tcp
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@iris:Active] config  b rule myrule list
    rule myrule {
       when HTTP_RESPONSE {
            HTTP::cookie remove "my-cookie"
    }
    }
    
    New TCP connection 2: 10.10.72.30(61682) <-> 10.10.70.110(80)
    ---------------------------------------------------------------
    1319007722.8772 (0.0038)  S>C
    ---------------------------------------------------------------
    48 54 54 50 2f 31 2e 31 20 32 30 30 20 4f 4b 0d    HTTP/1.1 200 OK.
    0a 44 61 74 65 3a 20 54 75 65 2c 20 31 38 20 4f    .Date: Tue, 18 O
    63 74 20 32 30 31 31 20 32 32 3a 31 35 3a 33 33    ct 2011 22:15:33
    20 47 4d 54 0d 0a 53 65 72 76 65 72 3a 20 41 70     GMT..Server: Ap
    61 63 68 65 2f 32 2e 30 2e 35 39 20 28 72 50 61    ache/2.0.59 (rPa
    74 68 29 0d 0a 4c 61 73 74 2d 4d 6f 64 69 66 69    th)..Last-Modifi
    65 64 3a 20 53 61 74 2c 20 31 31 20 4a 75 6e 20    ed: Sat, 11 Jun
    32 30 31 31 20 30 30 3a 33 31 3a 34 37 20 47 4d    2011 00:31:47 GM
    54 0d 0a 45 54 61 67 3a 20 22 36 36 37 61 2d 36    T..ETag: "667a-6
    37 2d 63 66 62 36 38 32 63 30 22 0d 0a 41 63 63    7-cfb682c0"..Acc
    65 70 74 2d 52 61 6e 67 65 73 3a 20 62 79 74 65    ept-Ranges: byte
    73 0d 0a 56 61 72 79 3a 20 41 63 63 65 70 74 2d    s..Vary: Accept-
    45 6e 63 6f 64 69 6e 67 0d 0a 43 6f 6e 74 65 6e    Encoding..Conten
    74 2d 45 6e 63 6f 64 69 6e 67 3a 20 67 7a 69 70    t-Encoding: gzip
    0d 0a 53 65 74 2d 43 6f 6f 6b 69 65 3a 20 6d 79    ..Set-Cookie: my
    2d 63 6f 6f 6b 69 65 3d 68 65 6c 6c 6f 77 6f 72    -cookie=hellowor
    6c 64 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67    ld..Content-Leng
    74 68 3a 20 39 36 0d 0a 4b 65 65 70 2d 41 6c 69    th: 96..Keep-Ali
    76 65 3a 20 74 69 6d 65 6f 75 74 3d 33 30 30 2c    ve: timeout=300,
    20 6d 61 78 3d 31 30 30 0d 0a 43 6f 6e 6e 65 63     max=100..Connec
    74 69 6f 6e 3a 20 4b 65 65 70 2d 41 6c 69 76 65    tion: Keep-Alive
    0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20    ..Content-Type:
    74 65 78 74 2f 68 74 6d 6c 3b 20 63 68 61 72 73    text/html; chars
    65 74 3d 55 54 46 2d 38 0d 0a 0d 0a 1f 8b 08 00    et=UTF-8........
    00 00 00 00 00 03 b3 c9 28 c9 cd b1 e3 b2 49 ca    ........(.....I.
    4f a9 04 52 19 86 76 e1 ae 3e ce fe be ae 8a 40    O..R..v..>.....@
    60 a3 0f e4 83 05 43 32 32 8b d5 8b 15 0c 0d f4    `.....C22.......
    80 c8 1c 48 02 29 a8 6c 66 6e ba 42 71 51 b2 ad    ...H.).lfn.BqQ..
    52 4a 7e ba 5e 7a 66 9a 92 82 3e 50 54 1f 6a a0    RJ~.^zf...>PT.j.
    3e c4 7c 00 fc 6a 57 13 67 00 00 00                >.|..jW.g...
    
    New TCP connection 1: 192.168.206.102(61682) <-> 172.28.17.33(80)
    ---------------------------------------------------------------
    1319007722.8773 (0.0043)  S>C
    ---------------------------------------------------------------
    48 54 54 50 2f 31 2e 31 20 32 30 30 20 4f 4b 0d    HTTP/1.1 200 OK.
    0a 44 61 74 65 3a 20 54 75 65 2c 20 31 38 20 4f    .Date: Tue, 18 O
    63 74 20 32 30 31 31 20 32 32 3a 31 35 3a 33 33    ct 2011 22:15:33
    20 47 4d 54 0d 0a 53 65 72 76 65 72 3a 20 41 70     GMT..Server: Ap
    61 63 68 65 2f 32 2e 30 2e 35 39 20 28 72 50 61    ache/2.0.59 (rPa
    74 68 29 0d 0a 4c 61 73 74 2d 4d 6f 64 69 66 69    th)..Last-Modifi
    65 64 3a 20 53 61 74 2c 20 31 31 20 4a 75 6e 20    ed: Sat, 11 Jun
    32 30 31 31 20 30 30 3a 33 31 3a 34 37 20 47 4d    2011 00:31:47 GM
    54 0d 0a 45 54 61 67 3a 20 22 36 36 37 61 2d 36    T..ETag: "667a-6
    37 2d 63 66 62 36 38 32 63 30 22 0d 0a 41 63 63    7-cfb682c0"..Acc
    65 70 74 2d 52 61 6e 67 65 73 3a 20 62 79 74 65    ept-Ranges: byte
    73 0d 0a 56 61 72 79 3a 20 41 63 63 65 70 74 2d    s..Vary: Accept-
    45 6e 63 6f 64 69 6e 67 0d 0a 43 6f 6e 74 65 6e    Encoding..Conten
    74 2d 45 6e 63 6f 64 69 6e 67 3a 20 67 7a 69 70    t-Encoding: gzip
    0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67 74 68    ..Content-Length
    3a 20 39 36 0d 0a 4b 65 65 70 2d 41 6c 69 76 65    : 96..Keep-Alive
    3a 20 74 69 6d 65 6f 75 74 3d 33 30 30 2c 20 6d    : timeout=300, m
    61 78 3d 31 30 30 0d 0a 43 6f 6e 6e 65 63 74 69    ax=100..Connecti
    6f 6e 3a 20 4b 65 65 70 2d 41 6c 69 76 65 0d 0a    on: Keep-Alive..
    43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 74 65    Content-Type: te
    78 74 2f 68 74 6d 6c 3b 20 63 68 61 72 73 65 74    xt/html; charset
    3d 55 54 46 2d 38 0d 0a 0d 0a 1f 8b 08 00 00 00    =UTF-8..........
    00 00 00 03 b3 c9 28 c9 cd b1 e3 b2 49 ca 4f a9    ......(.....I.O.
    04 52 19 86 76 e1 ae 3e ce fe be ae 8a 40 60 a3    .R..v..>.....@`.
    0f e4 83 05 43 32 32 8b d5 8b 15 0c 0d f4 80 c8    ....C22.........
    1c 48 02 29 a8 6c 66 6e ba 42 71 51 b2 ad 52 4a    .H.).lfn.BqQ..RJ
    7e ba 5e 7a 66 9a 92 82 3e 50 54 1f 6a a0 3e c4    ~.^zf...>PT.j.>.
    7c 00 fc 6a 57 13 67 00 00 00                      |..jW.g...
    
    
  • You can try something like the below in the HTTP Response event.

     

     

    HTTP::respond 302 Location "http://$host/portal/site/erp/SAD/" Set-Cookie [format "%s=%s; domain=%s; path=/; Expires=%s" $portalCookie $host "" "Thu, 01-Jan-1970 00:00:00 GMT"]
  • You can try something like the below in the HTTP Response event.

     

     

    HTTP::respond 302 Location "http://$host/xyz/" Set-Cookie [format "%s=%s; domain=%s; path=/; Expires=%s" $portalCookie $host "" "Thu, 01-Jan-1970 00:00:00 GMT"]