0

Is there any manner in which you would be able to set a cookie for a browser client side but not have it relayed with every POST/GET request?

2 Answers 2

2

Yes, use localStorage or sessionStorage. Both provide the ability to store data that is only available client-side. Assuming you want persistence beyond tabs, localStorage is the way to go.

Sign up to request clarification or add additional context in comments.

Comments

2

Is there any manner in which you would be able to set a cookie for a browser client side but not have it relayed with every POST/GET request?

No, there are not cookies that are client-side only. There is the reverse - cookies that are only server accessible.

If you don't want a server to see the data, then you must use something other than a cookie that is stored in the browser such as LocalStorage. The storage is still domain specific, but is only available to the Javascript in the page and is not sent to the server.

You can read about both LocalStorage and SessionStorage here on MDN.

// store a string in localStorage localStorage.setItem("myKey", str); // retrieve a string from localStorage var str = localStorage.getItem("myKey"); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.