2

I'm setting a cookie in Javascript:

document.cookie = "lang=" + lang + ";path=/;domain=" + window.location.hostname + ";";

If I check the cookies in the browser, I can see this one. But when I run :

@if (Response.Cookies.AllKeys.Contains("lang")) {
    @Response.Cookies["lang"].Value;
}

I get no output.

1 Answer 1

4
Response.Cookies 

should be

Request.Cookies

Request.Cookies cookies come from client (browser) to the server and Response.Cookies cookies are sent back to the client (browser) from the server.

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

1 Comment

Thank you for your explanation of the difference!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.