The
Wininet.dll contains many Win32 and network-related functions, including internet,ftp, below, which shows a cookie for IE. For example, CSDN login information can be saved for 2 weeks, you log in after the system time to 2 weeks, the landing information is invalid, use InternetSetCookie can set their own expiration date. First in IE login, log in to choose information to save 2 weeks, and then run the following code, after the operation you can adjust the date to 2010 see Effect:
Using System;
Using System.Text;
Using System.Runtime.InteropServices;
Namespace ConsoleApplication1 {class Program {///<summary>///set Cookie///</summary> [DllImport ("Wininet.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern bool InternetSetCookie (ST
Ring Lpszurlname, String lbszcookiename, string lpszcookiedata); <summary>///Get Cookie///</summary> [DllImport ("Wininet.dll", CharSet = CharSet.Auto, Setlas Terror = true)] public static extern bool InternetGetCookie (string URL, string name, StringBuilder data, ref int
DataSize);
static void Main (string[] args) {//Get the old StringBuilder cookie = new StringBuilder (new string (', 2048)); int datasize = cookie.
Length;
BOOL b= InternetGetCookie ("http://www.bianceng.cn", null, cookie, ref datasize); Deletes the old foreach (String fileName in System.IO.Directory.GetFiles (System.Environment.GetFolderPath) (EnVironment. Specialfolder.cookies)) {if (Filename.tolower ()).
IndexOf ("csdn") > 0) {System.IO.File.Delete ("csdn"); }//Generate a new foreach (String C in cookie.) ToString ().
Split (';'))
{string[] item = c.split (' = ');
String name = Item[0];
String value = Item[1] + "; expires=sun,22-feb-2099 00:00:00 GMT";
InternetSetCookie ("http://www.bianceng.cn", Name,value);
InternetSetCookie ("Http://forum.csdn.net", name, value);
InternetSetCookie ("Http://webim.csdn.net", name, value); } } } }