Reputation: 339
I am attempting to use javascript to set a cookie with an expiration date. Using Chrome, I can see that it creates it properly using the code below:
document.cookie = "IsAuthd" + '=' + "SomeVal" + ';expires=Sat, 08 March 2014 00:00:01 GMT';
However, when I execute an AJAX call directly after this (using jquery), the cookie is only half-passed in the request headers. In the request, I see:
Cookie: IsAuthd=SomeVal
But not the expiration. Can anyone explain why this is and why I can't send this WHOLE cookie over?
Here is the ajax code I use:
$.ajax({
type: 'GET',
url: '/Test/CollectCookie',
data: { },
cache: false,
success: function () {
console.log("done with ajax call");
}
});
Upvotes: 0
Views: 1231
Reputation: 324630
That's how cookies work. The expiry is only for the benefit of the browser. Passing it back and forth is needless overhead.
Upvotes: 1