Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7785867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:19:28+00:00 2026-06-01T20:19:28+00:00

I am using NSURLConnection to connect with a server, using a GET request. To

  • 0

I am using NSURLConnection to connect with a server, using a GET request. To login I am sending a GET request with url of the form

http://<myUserName>:<myPassword>@my.serverurl.com/user/login

an example URL will be

http://someusername:somepass@www.google.com/user/login 

When I login for the first time, and I pass the correct username and password, I am able to successfully login, and if I pass incorrect username or password I get a response from server saying my username and password is incorrect.. All is well then

But when I login with correct username/password, get into my home page. There I logout to go back to login screen. Now I enter incorrect username and password and try to login, I am getting response login is successfull..This is my problem.

That means all my subsequent login requests return successfull with incorrect username and password. I checked the same url (correct and incorrect) with the browser and there everything is working as it should be.

This is the code I am using to login

-(void)postRequest{
    NSMutableURLRequest *request    =   [[NSMutableURLRequest alloc] init] ; 
    [request setURL:[NSURL URLWithString:
              @"http://myusername:mypass@my.serverurl.com/user/login"]]; 
    [request setHTTPMethod:@"GET"];
//    [request setHTTPShouldHandleCookies:NO];   ==> I tried without this first

    loginRequestConnection  =   [[CustomURLConnection alloc]
                                      initCustomURLWithRequest:request 
                                      delegate:self 
                                      withTAG:LOGIN_REQUEST_CONNECTION];
    [request release];
}

Now CustomURLConnection is nothing but a subclass of NSURLConnection and added a tag to identify between multiple connection requests in the delegate

@interface CustomURLConnection : NSURLConnection{
}
@property()NSInteger tag;
@property(nonatomic, retain) NSMutableData *receivedData;

-(id)initCustomURLWithRequest:(NSURLRequest *)request delegate:(id)delegate withTAG:(NSInteger)tagInt;
@end

I think the problem is NSURLConnection request is storing the cookie somewhere and reusing them to subsequent requests. That is why I added

[request setHTTPShouldHandleCookies:NO];

to the code. But with or without that problem persist. So any other suggestion to what is causing this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:19:29+00:00Added an answer on June 1, 2026 at 8:19 pm

    try using this
    initWithURL:cachePolicy:timeoutInterval: and set cache policy to NSURLRequestReloadIgnoringCacheData

    Try adding this delegate method.

     - (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse {   
    return nil; 
    }
    

    Ensure that this method is called.

    Use NSURLCredentialStorage and removeCredential to erase your cache for credentials that are stored by NSURLConnection.

    Please check this answer as well.

    Hope that works

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using NSURLConnection to send request to server and receive response like this
I'm currently using NSURLConnection to test if I can successfully connect to a server.
iam currently using NSURLConnection class to hit my server and get some data from
I'm getting an image over HTTP, using NSURLConnection, as follows - NSMutableData *receivedData; -
I ve been working on accessing a server using NSURLConnection. I require a sample
My app connects to the Schwab OFX server using NSURLConnection . Unfortunately the server
I'm trying to connect to http://cmis.demo.nuxeo.org/nuxeo/atom/cmis/ with NSURLConnection . This demo web service is
I'm using a NSMutableURLRequest to connect to a web site to get a JSON
I am using NSURLConnection to download gzipped JSON from server. Is it possible to
i am using NSURLConnection to download file from server and storing it locally as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.