UNPKG

create-a-critique

Version:

Start a GoTHA app, it combines Go, Templ, HTMX and Alpine.js in the same bundle.

21 lines (17 loc) 641 B
function getCookie(name: string) { // Split the document.cookie string into individual cookies let cookies = document.cookie.split(';'); // Loop through the cookies for (let i = 0; i < cookies.length; i++) { // Get the cookie and trim any leading spaces let cookie = cookies[i].trim(); // Check if the cookie name matches the name we're looking for if (cookie.indexOf(name + '=') === 0) { // Return the cookie value (substring after the cookie name and equals sign) return cookie.substring(name.length + 1); } } // Return null if the cookie was not found return null; } export { getCookie };