Class CookieUtils

java.lang.Object
com.facebook.capi.sdk.utils.CookieUtils

public class CookieUtils extends Object
Util functions to help process and provide suggestions on the cookies
  • Constructor Details

    • CookieUtils

      public CookieUtils(List<FbcParamConfig> fbcParamConfigs)
      Default settings for param configs
      Parameters:
      fbcParamConfigs - default setting configs
  • Method Details

    • setEtldPlusOneAndSubDomainIndex

      public void setEtldPlusOneAndSubDomainIndex(String etldPlusOne, int subdoainIndex)
      Set the default value for etldPlusOne and subdoainIndex
      Parameters:
      etldPlusOne - reset etld+1
      subdoainIndex - reset subdomain index
    • preprocessCookies

      public String preprocessCookies(Map<String,String> cookies, String cookieName, Map<String,CookieSetting> updatedCookieMap)
      Preprocess cookies to make sure we have the correct language token. If not, update the cookie
      Parameters:
      cookies - Map of cookies. Key is cookie name, value is cookie value
      cookieName - Cookie name to be processed
      updatedCookieMap - A map to store updated cookies. key is the cookie name, value is CookieSettings. If cookie already exist and no need update, return null.
      Returns:
      updated cookie value. Return null if current cookie value is empty or invalid.
    • getNewFbcPayloadFromQuery

      public String getNewFbcPayloadFromQuery(Map<String,String[]> queries, String referrer)
      Get the new fbc payload from query string and referrer.
      Parameters:
      queries - Map of query string
      referrer - full referrer url
      Returns:
      new updated fbc payload
    • getUpdatedFbpCookie

      public CookieSetting getUpdatedFbpCookie(String existingFbp, Map<String,CookieSetting> updatedCookieMap)
      Check if we need update fbp cookie. If yes, update it and return the new fbp cookie.
      Parameters:
      existingFbp - existing fbp cookie value
      updatedCookieMap - A map to store updated cookies. key is the cookie name, value is CookieSettings. If cookie already exist and no need update, return null.
      Returns:
      CookieSettings that should be updated. If cookie already exist and no need update return null.
    • getUpdatedFbcCookie

      public CookieSetting getUpdatedFbcCookie(String existingFbc, String newFbcPayload, Map<String,CookieSetting> updatedCookiesMap)
      Check if we need update fbc cookie. If yes, update it and return the new fbc cookie.
      Parameters:
      existingFbc - existing fbc payload
      newFbcPayload - new fbc payload
      updatedCookiesMap - A map to store updated cookies. key is the cookie name, value is CookieSettings
      Returns:
      CookieSettings that should be updated. If cookie already exist and no need update return null.