{{ document.cookie }} – Get Cookie Value

Variables passed to the current script via HTTP Cookies.

The tag uses PHP $_COOKIE method

Basic usage:

{{ document.cookie('cookie_saved_on_client_side') }}

 How to save a cookie using JS:

  <script>

  document.cookie = [
    `cookie_saved_on_client_side=${encodeURIComponent("Some value to store")}`,
    "path=/",
    "max-age=28800",     // 8 hours
    "SameSite=Lax",
    "Secure"
  ].join("; ");

  </script>


What are your feelings

Leave a Reply

Updated on March 6, 2026