Why isn't my filtering code working with a cookie as product.tag value?

Topic summary

A developer is experiencing issues with Liquid templating code that filters product tags based on a cookie value.

Working code:

  • Successfully filters when using a hardcoded string: {% if product.tags contains '25KG' %}

Non-working code:

  • Fails when attempting to use a cookie variable: {% if product.tags contains userregionid %}
  • The cookie is assigned via: {% assign userregionid = cookies.user_region %}
  • The cookie contains the value ‘25KG’

Issue:
The filtering logic doesn’t work when substituting the hardcoded ‘25KG’ with the userregionid variable, despite the cookie containing the same value. The question remains unanswered with no resolution or explanation provided yet.

Summarized with AI on November 12. AI used: claude-sonnet-4-5-20250929.

When i use this code it works

{% assign userregionid = cookies.user_region %}

    {% for tag in product.tags %} {% if product.tags contains '25KG'%} <<<<

    But when i use this userregionid have a value of ‘25KG’ from my cookie my filtering code wont work

    {% assign userregionid = cookies.user_region %}

      {% for tag in product.tags %} {% if product.tags contains userregionid%} <<<<