Read all cookies

Hi
following is the code to read all the existing cookies on your computer .

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace GetCookie
{
class Program
{
static void Main(string[] args)
{

Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine(“============= Get Cookies ============== “);
//Get cookies folder path
string cookieFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Cookies);
Console.WriteLine(“\n\nCookies Folder := ” + cookieFolderPath);
Console.WriteLine(“\n\n=============End Get Cookies ============== “);

// Get names of all cookie files

System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(cookieFolderPath);
FileInfo[] files = dirInfo.GetFiles();

foreach (FileInfo file in files)
{

if(!file.Name.Contains(“index”))
{

// call function to read cookie file
Readcookie(file.FullName);

}
}

}
public static void Readcookie(string path)
{

FileInfo fi = new FileInfo(path);
Console.ForegroundColor = ConsoleColor.White;
Console.Write(“Reading Cookie :”);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(fi.FullName);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(“Cookie Name :” );
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(fi.Name);
StreamReader sr = new StreamReader(fi.FullName);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(“Cookie Value :”);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine (sr.ReadToEnd());

}

}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s