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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:15:34+00:00 2026-05-17T17:15:34+00:00

I have been working using openFrameworks, on a problem that is posted on the

  • 0

I have been working using openFrameworks, on a problem that is posted on the forum:
http://www.openframeworks.cc/forum/viewtopic.php?f=8&t=4765

Essentially, I have used an an set of files, ofxHttpUtils, which uses poco to post to web forms.
The example code I have used is at:
github.com/arturoc/ofxHttpUtils/blob/gh-pages/example/src/testApp.cpp

I want to POST to a login page, a username and password, and then I am aiming to scrape text off the response… that’s the aim, via an iPhone app.

The problem I am having is cookies. The ofxHttpUtils addon does not have any method for remembering the cookie from a POST, so the response I get back is just the login page. I have searched for methods to try and capture the cookie, and there seems to be something in Objective C here, from another post to Stack Overflow:

NSHTTPURLResponse   * response;
NSError             * error;
NSMutableURLRequest * request;
request = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://temp/gomh/authenticate.py?setCookie=1"]
                                        cachePolicy:NSURLRequestReloadIgnoringCacheData 
                                    timeoutInterval:60] autorelease];

[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];    
NSLog(@"RESPONSE HEADERS: \n%@", [response allHeaderFields]);

// If you want to get all of the cookies:
NSArray * all = [NSHTTPCookie cookiesWithResponseHeaderFields:[response allHeaderFields] forURL:[NSURL URLWithString:@"http://temp"]];
NSLog(@"How many Cookies: %d", all.count);
// Store the cookies:
// NSHTTPCookieStorage is a Singleton.
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:all forURL:[NSURL URLWithString:@"http://temp"] mainDocumentURL:nil];

// Now we can print all of the cookies we have:
for (NSHTTPCookie *cookie in all)
    NSLog(@"Name: %@ : Value: %@, Expires: %@", cookie.name, cookie.value, cookie.expiresDate); 


// Now lets go back the other way.  We want the server to know we have some cookies available:
// this availableCookies array is going to be the same as the 'all' array above.  We could 
// have just used the 'all' array, but this shows you how to get the cookies back from the singleton.
NSArray * availableCookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:[NSURL URLWithString:@"http://temp"]];
NSDictionary * headers = [NSHTTPCookie requestHeaderFieldsWithCookies:availableCookies];

// we are just recycling the original request
[request setAllHTTPHeaderFields:headers];

request.URL = [NSURL URLWithString:@"http://temp/gomh/authenticate.py"];
error       = nil;
response    = nil;

NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"The server saw:\n%@", [[[NSString alloc] initWithData:data encoding: NSASCIIStringEncoding] autorelease]);

I am not sure how/where to implement this, so that I can integrate with my my ofxHttpUtils code so that the cookie is remembered and served in calls to the password protected site. Can anyone help? I know this request is a little unspecific… I hope you can see what I’m trying to do…

  • 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-17T17:15:35+00:00Added an answer on May 17, 2026 at 5:15 pm

    Since you’re already using OF, it would likely be simpler to stick with that. You’re going to have to extend ofxHttpUtils to handle cookies, either by making it smarter so it handles cookies intelligently, or by leaving it dumb while letting you grab and set cookies as needed. Poco::Net, which ofxHttpUtils is based on, has no problem with cookies – it includes functions like HTTPResponse::getCookies().

    The most straightforward approach is the dumb one:

    • add ofxHttpForm::setCookies() so you can pass cookies into the module and getCookies() so the module can access them
    • modify ofxHttpUtils::doPostForm() to pull cookies from the ofxHttpForm and set them on the Poco HTTPRequest
    • modify the ofxHttpRequest constructor to pull the cookies from the Poco HTTPResponse and provide a way for your code to get at them

    Your code would then grab the cookies sent back after the log-in POST and set them on all future requests.

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

Sidebar

Related Questions

I have been working on on an AJAX chat application using php, mysql. It's
I have been working on the Knapsack problem using genetic algorithms. But I have
I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#)
I have recently been working with Python using Komodo Edit and other simpler editors
I have just been re-working an old bit of compiler-like code written using bison.
I am working on a web app using C# and asp.net I have been
G'day, I am working with a group of offshore developers who have been using
I have been working with a string[] array in C# that gets returned from
I have been working on some legacy C++ code that uses variable length structures
I have been working on winforms using C# in my company for quite a

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.