Hi
I'm trying to pass firstname and name from a html page to another html page (without using server code like php or asp.net) using cookies. This works partially because i get the firstname in the first input of the page action.html but also in the second input. How can i get the name in the second input in action.html?
Thanks
V.
first page:
-----------------------
action.html:

Pankajkumar PatelRank #181 · 13.4K reputationPosted Nov 17, 2022, 11:45 PM EST
Hi Valerie Meunier,
Instead of cookies you can use query string to another html-page as following way:
f1.html
f2.html
Hope, this will help you!
Deepak RawatRank #646 · 3.7K reputationPosted Apr 26, 2023, 10:19 AM EDT
On the second HTML page, you can read the values of the cookies by accessing the document.cookie property:
const cookies = document.cookie.split(';'); const cookie1 = cookies.find(c => c.trim().startsWith('cookie1=')); const cookie2 = cookies.find(c => c.trim().startsWith('cookie2=')); const value1 = cookie1 ? cookie1.split('=')[1] : null; const value2 = cookie2 ? cookie2.split('=')[1] : null; console.log("cookie1 value:", value1); console.log("cookie2 value:", value2);how you can set two cookies named "cookie1" and "cookie2" with the values "value1" and "value2" respectively, and then redirect to another HTML page:
On the first HTML page:
document.cookie = "cookie1=value1"; document.cookie = "cookie2=value2"; window.location.href = "secondpage.html";