Thanks for all replies. Here is my strange solution. :) I am writing this since someone may need it in the future.
The cookie that I receive does not contain a specific [name,value] pair like [logged,true]. The only thing that I receive is something like:
Set-Cookie: ASP.NET_SessionId=ah0b2kj40oi0vuufv0mmot35; path=/; HttpOnly\r\n
So, I thought i am on the wrong direction and tried to find another way to analyze if login is successful or not. My solution is to use the StatusCode of the response. I realised that (thnx to Jason's comment about error code 401) server responds back with a HTTP 302 Found status code if login is successful. But if login is unsuccessful, it responds back with the same login page (i.e. HTTP 200 OK). So depending on the received response's HTTP code, I decide if it is successful or not. Here is the sample code:
//In LoginForm.cs
if (((HttpWebResponse)request.GetResponse()).StatusCode.ToString().Equals("Found"))
{
nextUrl = ((HttpWebResponse)request.GetResponse()).Headers.Get(4);
StringBuilder FullUrl = new StringBuilder(this.server_address);
FullUrl.Append(nextUrl);
this.setSecretURL(FullUrl.ToString());
setLoginSuccess(true);
// now we can send out cookie along with a request for the protected page
request = WebRequest.Create(SECRET_PAGE_URL) as HttpWebRequest;
request.CookieContainer = cookies;
StreamReader responseReader = new StreamReader(request.GetResponse().GetResponseStream());
// and read the response
result = responseReader.ReadToEnd();
responseReader.Close();
} else
{
setLoginSuccess(false);
}