Login Website, curious Cookie Problem

Posted by Collin Peters on Stack Overflow See other posts from Stack Overflow or by Collin Peters
Published on 2010-03-19T09:16:49Z Indexed on 2010/03/19 9:21 UTC
Read the original article Hit count: 353

Filed under:
|
|
|
|

Hello,

Language: C# Development Environment: Visual Studio 2008

Sorry if the english is not perfect.

I want to login to a Website and get some Data from there. My Problem is that the Cookies does not work. Everytime the Website says that I should activate Cookies but i activated the Cookies trough a Cookiecontainer.

I sniffed the traffic serveral times for the login progress and I see no problem there. I tried different methods to login and I have searched if someone else have this Problem but no results...

Login Page is: "www.uploaded.to", Here is my Code to Login in Short Form:

        private void login()
        {
        //Global CookieContainer for all the Cookies
        CookieContainer _cookieContainer = new CookieContainer();

        //First Login to the Website
        HttpWebRequest _request1 = (HttpWebRequest)WebRequest.Create("http://uploaded.to/login");
        _request1.Method = "POST";
        _request1.CookieContainer = _cookieContainer;

        string _postData = "email=XXXXX&password=XXXXX";
        byte[] _byteArray = Encoding.UTF8.GetBytes(_postData);

        Stream _reqStream = _request1.GetRequestStream();

        _reqStream.Write(_byteArray, 0, _byteArray.Length);
        _reqStream.Close();

        HttpWebResponse _response1 = (HttpWebResponse)_request1.GetResponse();
        _response1.Close();


        //########################

        //Follow the Link from Request1
        HttpWebRequest _request2 = (HttpWebRequest)WebRequest.Create("http://uploaded.to/login?coo=1");
        _request2.Method = "GET";
        _request2.CookieContainer = _cookieContainer;

        HttpWebResponse _response2 = (HttpWebResponse)_request2.GetResponse();
        _response2.Close();


        //#######################

        //Get the Data from the Page after Login
        HttpWebRequest _request3 = (HttpWebRequest)WebRequest.Create("http://uploaded.to/home");
        _request3.Method = "GET";
        _request3.CookieContainer = _cookieContainer;

        HttpWebResponse _response3 = (HttpWebResponse)_request3.GetResponse();
        _response3.Close();

        }

I'm stuck at this problem since many weeks and i found no solution that works, please help...

© Stack Overflow or respective owner

Related posts about c#

Related posts about cookie