views:

405

answers:

2

Yo, guys do you know how to create cookies for IE manually? I mean create programmatically a cookie from scratch with custom domain, expiration time, path and token value.

Thanks a lot in advance!

A: 

Cookies are usually created on a server using apis such as :javax.servlet.http.Cookie . That API allows you to specify the items you're asking about. The browser merely stashes the cookie it receives from the server.

The specific contents of a cookie are entirely application specific and are quite likely encrypted so that you cannot synthesise one without access to that particular server's infrastructure.

You can use javascript in the browser to manipulate cookies as described here, but unless you know what the server is expecting this does you little good.

djna
Downvote? Please say why, then we can all learn.
djna
+2  A: 

Do you mean a cookie like this:

var date = new Date();
var days = 10000;
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
document.cookie = "test" + "; expires= " + date.toGMTString(); +"; path=/";
alert(document.cookie);
waqasahmed