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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:06:46+00:00 2026-06-02T20:06:46+00:00

I am trying to make a basic authentication system in iOS that sends a

  • 0

I am trying to make a basic authentication system in iOS that sends a POST to Django and on the Django side authenticates the user and starts a session. Right now I am able to send the user information by passing the values as data in the URL and authenticating it, but how do I retrieve the session data or cookie from the Django response? When I try to store or print out the cookie, it tells me the array is empty. I have tried both request.requestCookies and request.responseCookies.

NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"test_user", @"username", @"pass", @"password", nil];

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:8000/login/"]];

NSError *error;
NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error];

if ( error ) {
    NSLog( @"ERROR - %@", error.localizedDescription );
} else {
    __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request addRequestHeader: @"Content-Type" value:@"application/json; charset=utf-8"]; 
    [request appendPostData:data];
    [request setRequestMethod:@"POST"];

    [request setCompletionBlock:^{

        UIAlertView *alerView = [[UIAlertView alloc] initWithTitle:@"Login"
                                                           message:@"Login was sent"
                                                          delegate:nil
                                                 cancelButtonTitle:nil
                                                 otherButtonTitles:@"Ok", nil];
        [alerView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO];

        NSLog(@"RESPONSE: %@", [[NSString alloc] initWithData:request.responseData encoding:NSUTF8StringEncoding]);//, [request.requestCookies objectAtIndex:0]);
        NSLog(@"COOKIE: %@", [request.requestCookies objectAtIndex:0]);
        [ASIHTTPRequest addSessionCookie:[request.requestCookies objectAtIndex:0]];

    }];
  • 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-02T20:06:48+00:00Added an answer on June 2, 2026 at 8:06 pm

    Okay, so I resolved this issue and it turns out that on the server side I was putting in the data but not officially logging in with Django (was not returning the proper cookies) which meant my app was not receiving the proper header.

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

Sidebar

Related Questions

I'm trying to make a basic counter. The idea is that the user presses
I'm trying to make a basic user login. In the PHP page that logs
Im trying to make an extension to Safari that authenticates with http://myphotodiary.com 's API.
I am trying to make a basic iphone app that shows nearby tweets. I
I'm trying to make a basic model of the solar system in Direct X.
Im trying to make a basic email system in Java. I have a server
I'm trying to make a basic Windows application that builds a string out of
I am trying to make a basic java console based menu system. I have
Hi I am trying to make a basic form that adds a value of
I'm trying to make a basic Address class, that many different other classes can

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.