Maizere Pathak.Nepal
Maizere Pathak.Nepal

Reputation: 2413

Javascript setting cookie

It is said that setting cookie through javascript doesn't travel through the HTTP header.What could be the reason behind this?Why javascript cookie dont travel through HTTP header?

document.cookie ='ppkcookie1=testcookie';

Upvotes: 0

Views: 341

Answers (2)

Guffa
Guffa

Reputation: 700342

Cookies set by Javascript are sent in the HTTP header, but not at the time when you set the cookie. It will be included in the header the next time you make a request to the server.

Upvotes: 1

Quentin
Quentin

Reputation: 943571

If you fix the syntax error (the string literal is was, until the question was edited, missing its closing '), then it does (although, obviously, not until the next HTTP request is made).

Upvotes: 1

Related Questions