问题描述
我试图在c#winform应用程序中使用wininet在客户端创建一个cookie。
所以我使用这个代码:
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
返回true,但我在 Internet临时文件文件夹中找不到该Cookie 。
任何线索?
InternetSetCookie
returns me true but I can't find the cookie in the Temporary Internet Files folder.Any clue ?
推荐答案
我想如果你没有指定过期日期,那么你创建一个会话cookie。如果你想要持久的cookie尝试指定到期日期。
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.
我假设这样的cookie只存储在RAM,而不是序列化到磁盘。
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.
如果您选中您看到:
这篇关于InternetSetCookie不会在临时Internet文件中存储cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!