Forum Discussion

James_78615's avatar
James_78615
Icon for Nimbostratus rankNimbostratus
Apr 21, 2009

Cookie persistence for certain host headers

Hi,

 

 

I have the requirement to enable cookie persistence when a user hits a particular subdomain for a site.

 

 

For example, insert a cookie and use cookie persistence for abc.site.com but any other requests for *.site.com should be load balanced without persistence.

 

 

Is this possible using the following rules?

 

 

profile persist abc_passive_cookie

 

defaults from cookie

 

mode cookie

 

cookie mode passive

 

cookie name "abc_passive_cookie"

 

 

 

virtual WebVS

 

pool WebPool

 

destination 1.1.1.1:http

 

ip protocol tcp

 

rules abc_persist_cookie_insert

 

profiles

 

http

 

tcp

 

persist abc_passive_cookie

 

 

 

rule abc_persist_cookie_insert

 

when HTTP_REQUEST {

 

if { ([string tolower [HTTP::host]] starts_with "abc.") } {

 

persist cookie insert abc_persist_cookie

 

}

 

}

 

 

Thanks

 

James

 

 

 

  • Hi James,

    Since you are associating a profile persistence cookie to the vip resource then you could get a way with simply doing the following:

     
     when HTTP_REQUEST { 
        if { not ([string tolower [HTTP::host]] equals "abc.site.com") } { 
          persist none 
        } 
      } 
     

    hope this helps

    CB

  • Thanks CB, that works great.

     

     

    Is it possible to use an irule to insert a persist cookie without assigning a persistence profile to the vip? When I tried to do this I got an error when creating the irule.

     

     

    Thanks

     

    James
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    No, you must have a cookie insert persistence profile added to the VIP in order to use 'persist cookie insert'.

     

     

    Aaron