:doc:`ElasticLoadBalancing <../../elb>` / Client / create_app_cookie_stickiness_policy

***********************************
create_app_cookie_stickiness_policy
***********************************



.. py:method:: ElasticLoadBalancing.Client.create_app_cookie_stickiness_policy(**kwargs)

  

  Generates a stickiness policy with sticky session lifetimes that follow that of an application-generated cookie. This policy can be associated only with HTTP/HTTPS listeners.

   

  This policy is similar to the policy created by  CreateLBCookieStickinessPolicy, except that the lifetime of the special Elastic Load Balancing cookie, ``AWSELB``, follows the lifetime of the application-generated cookie specified in the policy configuration. The load balancer only inserts a new stickiness cookie when the application response includes a new application cookie.

   

  If the application cookie is explicitly removed or expires, the session stops being sticky until a new application cookie is issued.

   

  For more information, see `Application-Controlled Session Stickiness <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html#enable-sticky-sessions-application>`__ in the *Classic Load Balancers Guide*.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/elasticloadbalancing-2012-06-01/CreateAppCookieStickinessPolicy>`_  


  **Request Syntax**
  ::

    response = client.create_app_cookie_stickiness_policy(
        LoadBalancerName='string',
        PolicyName='string',
        CookieName='string'
    )
    
  :type LoadBalancerName: string
  :param LoadBalancerName: **[REQUIRED]** 

    The name of the load balancer.

    

  
  :type PolicyName: string
  :param PolicyName: **[REQUIRED]** 

    The name of the policy being created. Policy names must consist of alphanumeric characters and dashes (-). This name must be unique within the set of policies for this load balancer.

    

  
  :type CookieName: string
  :param CookieName: **[REQUIRED]** 

    The name of the application cookie used for stickiness.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {}
      
    **Response Structure**

    

    - *(dict) --* 

      Contains the output for CreateAppCookieStickinessPolicy.

      
  
  **Exceptions**
  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.AccessPointNotFoundException`

  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.DuplicatePolicyNameException`

  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.TooManyPoliciesException`

  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.InvalidConfigurationRequestException`

  

  **Examples**

  This example generates a stickiness policy that follows the sticky session lifetimes of the application-generated cookie.
  ::

    response = client.create_app_cookie_stickiness_policy(
        CookieName='my-app-cookie',
        LoadBalancerName='my-load-balancer',
        PolicyName='my-app-cookie-policy',
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'ResponseMetadata': {
            '...': '...',
        },
    }

  