I'm trying to create a cookie on client side using wininet from a c# winform application. So I use this code:
[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool InternetSetCookie
(
string lpszUrlName,
string lbszCookieName,
string lpszCookieData
);
private void btnRestaure_Click(object sender, EventArgs e)
{
try
{
var result = InternetSetCookie("www.mydomain.com", "MyCookie",
"value=helloworld");
}
catch(Exception ex)
{
}
}
InternetSetCookie
returns me true but I can't find the cookie in the Temporary Internet Files folder.
Any clue ?
I think if you don't specify an expiration date then you create a session cookie. If you want a persistent cookie try specifying an expiration date.
I assume that such a cookie is only stored in RAM and not serialized to disk. And most likely only visible to your own process.
If you check the MSDN documentation for InternetSetCookie you see: