다음을 통해 공유


Now about persistent cookies

This time is about persitent cookies.

First... how to find where are the cookies located from C#:
Directory.GetFiles( Environment.GetFolderPath( Environment.SpecialFolder.Cookies )

Now you have a list with all the persistent cookie on your hard drive.
You just need to parse them to make some sense of what's in there:

You need first to load the file and split everything on an array of string delimited by "\n*\n

string[] cookieLines = strCookie.Split( new char[] { '\n' } , StringSplitOptions.RemoveEmptyEntries );

Name = cookieLines[0];
Value = cookieLines[1];
string domainPath = cookieLines[2];
Domain = domainPath.Substring( 0 , domainPath.IndexOf( '/' ) );
Path = domainPath.Substring( domainPath.IndexOf( '/' ) );
Secure = Int32.Parse( cookieLines[3] , System.Globalization.CultureInfo.InvariantCulture );
long RHalf = long.Parse( cookieLines[4] );
long LHalf = long.Parse( cookieLines[5] , System.Globalization.CultureInfo.InvariantCulture );
Expiry = new DateTime( (long)Math.Round( 0.0001 * ( RHalf + 4294967296 * LHalf ) ) - 11644473600000 );

Let me know if you have any comments, ideas about this.

Thanks,
Ionutz