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 6998005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:21:21+00:00 2026-05-27T20:21:21+00:00

In my iPhone application, on login to web services I get a session ID

  • 0

In my iPhone application, on login to web services I get a session ID which gets changed on every login. I want to use that session ID for y other view controllers so that I would not have to use username password again and again and also I have to the session ID with the other links of web services to get the required JSON data to iPhone.

Should I define it as a macro or there is another way to do this.

session:"7e5085390e1877fd83f7346093c8304b"

If it can be done with macro then how can i achieve this?

On login url used as:

NSString *urlAsString = [NSString stringWithFormat:@"http://url/rest/mobile/session"];

NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url]; 

[urlRequest setTimeoutInterval:30.0f];

[urlRequest setHTTPMethod:@"POST"];

[urlRequest addValue:user forHTTPHeaderField:@"uid" ];
[urlRequest addValue:password forHTTPHeaderField:@"passwd" ];

When getting data for other views:

NSString *urlAsString = [NSString stringWithFormat:@"http://url/rest/assetgroups/7e5085390e1877fd83f7346093c8304b"];

Please let me have your suggestions

  • 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-27T20:21:21+00:00Added an answer on May 27, 2026 at 8:21 pm

    As a Global Variable

    Since Objective-C is a superset of C, one approach is to simply make a global variable, just like you would in C. You want to declare the variable in a header file, like this:

    Globals.h

    extern NSString *sessionId;
    

    Any .m file that needs to use sessionId can #import "Globals.h" to get the declaration.

    You also need to define the variable in one of your .m files. For example, you could add this to main.m, outside of any function definition:

    main.m

    NSString *sessionId;
    

    As an Application Delegate Property

    Another approach is to make the variable be a property of your application delegate, since that is a globally-accessible object already. You need to declare it in AppDelegate.h:

    AppDelegate.h

    @interface AppDelegate
    
    @property (strong, nonatomic) NSString *sessionId;
    
    // other properties and methods of AppDelegate here
    
    @end
    

    and you synthesize it in AppDelegate.m:

    @implementation AppDelegate {
        // ivars here
    }
    
    @synthesize sessionId = _sessionId;
    
    // Rest of AppDelegate method definitions and synthesizers here
    
    @end
    

    and you can access the property like this:

    ((AppDelegate *)[UIApplication sharedApplication].delegate).sessionId = whatever();
    NSLog(@"session id = %@", ((AppDelegate *)[UIApplication sharedApplication].delegate).sessionId);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an IPhone application that I want to attempt login and do some
I am Making an Iphone application which is web-service enabled. Also I have skeleton
I am about to start to developing an iPhone application that should login and
I am making an iphone application which has user information on a web server.
I know that SSO is possible for web application, so I want to is
I am making an iphone application in which after login we will go through
I'm developing an iPhone application where I wish to authenticate (login form) on a
hai all, in my iphone application i have a login view with two text
My iPhone application has several views and some viewControllers for that views. I need
I am developing an iPhone application that persists data to a SQLite3 database. For

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.