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

  • SEARCH
  • Home
  • 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 6876853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:31:46+00:00 2026-05-27T04:31:46+00:00

I got the following situation. I’m doing an iPhone app with tabbarcontroller and navigation

  • 0

I got the following situation. I’m doing an iPhone app with tabbarcontroller and navigation controller. After using the app to log into a web-server (which provides the webservices) to get a session cookie, I click on the tabbarnavigation menu which makes a request to one of the webservices. Calling this webservice, I got a handle status code that tells me im not logged into server, even though the app had logged into the web-server successfully the first time. So i’m not sure what i’m doing wrong I leave here snippet of my code.

AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [super application:application didFinishLaunchingWithOptions:launchOptions];
    [self initTabBarMenu];

    return YES;
}    
// call when the app is not login
- (void) showLogin 
{
    loginViewController = [[LoginViewController alloc] init];
    [self.tabBarController presentModalViewController:loginViewController animated:YES];
}

LoginViewController

- (void) viewDidLoad
{
    [super viewDidLoad];
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *username = [defaults objectForKey:@"usernameApp"];
    NSString *password = [defaults objectForKey:@"passwordAp"];

    if (![StrUtil isEmpty:username] && ![StrUtil isEmpty:password])
    {
        userField.text = username;
        passwordField.text = password;
        [self loginCheck];
    }

}

- (void) loginCheck
{
    NSString *url = @"http://localhost/service/login";

     ASIFormDataRequest *theRequest = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:url]];
    [theRequest setUseKeychainPersistence:YES];  
    [theRequest setDelegate:self];
    [theRequest addPostValue:userField.text forKey:@"username"];
    [theRequest addPostValue:passwordField.text forKey:@"password"];
    [theRequest setDidFinishSelector:@selector(loginDone:)];
    [theRequest setDidFailSelector:@selector(loginFailed:)];
    [theRequest startAsynchronous];
    [userField resignFirstResponder];
    [passwordField resignFirstResponder];
}

- (void) loginResponse:(ASIFormDataRequest *)theRequest
{
    nsData = [[NSDictionary alloc] initWithDictionary:[theRequest.responseString JSONValue]];
    [self hideProgress];

    if ([[nsData objectForKey:@"status"] integerValue] == 1)
    {

        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults setObject:userField.text forKey:@"usernameApp"];
        [defaults setObject:passwordField.text forKey:@"passwordApp"]; 
        [defaults synchronize];
        // Remove current view controller
        [self.parentViewController dismissModalViewControllerAnimated:YES];
    }
    else
    {
        [self showAlert:@"Problem"];
    }
}

Here is the problem: when i get the menu, Im not getting any data from my webservices, actually the app doesnt even try to call it, I’m using a BaseController to call every single webservice from there so I got my HomeViewController that extends from BaseController, so I got a generic method to call webservice on my BaseController like this:

- (void) callRequest
{
    //url is a NSString and you can set on HomeviewController
    if ([StrUtils isEmpty:url]) return;
    request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //[request setDownloadCache:[ASIDownloadCache sharedCache]];
    [request setCachePolicy:ASIAskServerIfModifiedCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy];
    [request setSecondsToCache:60*60*24*7]; // Cache for 7 days
    [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];

    [request setDelegate:self];
    [request setResponseEncoding:NSUTF8StringEncoding];
    [request setDefaultResponseEncoding:NSUTF8StringEncoding];
    [request setDidFinishSelector:@selector(requestFinished:)];
    [request setDidFailSelector:@selector(finishedWithError:)];
    [request setTimeOutSeconds:15];
    [request startAsynchronous];
}

- (void) requestFinished:(ASIHTTPRequest*)theRequest
{
    NSString *responseString = [theRequest responseString];
    nsData = [[NSDictionary alloc] initWithDictionary:[responseString JSONValue]];

    if ([[receivedData objectForKey:@"status"] integerValue] == 1)
    {
        return [(AppDelegate *)[[UIApplication sharedApplication] delegate] showLogin];
    }   
}

And then i Call the webservice from viewDidLoad

- (void) viewDidLoad
{
    [super viewDidLoad];
    [self callRequest];

}

HomeViewController

- (id) init
{
    if ((self = [super init]))
    {
        self.title = @"My Home";
        self.url = @"http://localhost/services/gethome"
    }

    return self;
}

So in summary, the problem is: i can not get any data for any section from my tabbarnavigation. The first time i click on 1 item, it loads loginviewcontroller (even though login was previously successful) and then call the webservice to the login in again. And directly after the second login, i can not get any data.

Well I’m not sure what i can do, thanks for all your suggestion and answers.

  • 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-05-27T04:31:47+00:00Added an answer on May 27, 2026 at 4:31 am

    Your problem could be that you’re not accepting cookies in your login request. Test to see what the value of your cookies are after the login call.

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

Sidebar

Related Questions

I've got the following situation A rails application that makes use of rjs /
I've got the following situation: var totalRecords = (from entry in invalidAccEntryRepository select entry).Where(entry
I've got the following situation: A User object has a Set of Permission objects
We've got the following situation, running from a single domain: Page A uses window.open()
I've got the following situation: <h2>This text is <span>pretty awesome</span></h2> I'm trying to give
I've got the following regex that was working perfectly until a new situation arose
Here is the situation. I've got the following interfaces: public interface Parent { }
Got myself in a funny situation: page has three tables. Using sortEnd, any time
I've got the following situation with ActiveRecord (in Rails 2.3.8): class Order < ActiveRecord::Base
I've got the following situation setup to model a Customer with multiple addresses and

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.