Search code examples
androidhttpcookiesmismatch

Cannot convert from BasicCookieStore to CookieStore


I am going to use cookies in my application so I don`t have to re-login for each requst I make to the server. Further on I have been looking on examples, and it seems that this is done in each of them:

CookieStore mCookieStore  = new BasicCookieStore(); 

However, when I try to do this I only get the error:

Cannot convert from BasicCookieStore to CookieStore

Thanks for any help!


Solution

  • I guess you import the wrong java class.

    The correct ones:

    import org.apache.http.client.CookieStore;
    

    not

    import java.net.CookieStore;
    

    BasicCookieStore implements CookieStore. You should be able to convert from BasicCookieStore to CookieStore.