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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:09:05+00:00 2026-06-08T08:09:05+00:00

Im doing an iphone application where i login using OAuth apis of the website

  • 0

Im doing an iphone application where i login using OAuth apis of the website for the login process and the status in the uiwebview remains as logged in all the time. I thought clearing the cookies in the uiwebview would help me logout. I want a logout option per say to the app. I have done this to clear all the cookies in uiwebview.

1) i have created a script.js and added it to the project which has the following code

function deleteAllCookies() {
    var cookies = document.cookie.split(";");

    for (var i = 0; i < cookies.length; i++) {
       var cookie = cookies[i];
       var eqPos = cookie.indexOf("=");
       var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
       document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }
}

2) i have added this code in one of the view controller which has a logout button. As soon as the botton is clicked, this code is executed

- (void)injectJavascript:(NSString *)resource {
NSString *jsPath = [[NSBundle mainBundle] pathForResource:resource ofType:@"js"];
NSString *js = [NSString stringWithContentsOfFile:jsPath encoding:NSUTF8StringEncoding error:NULL];

[webView stringByEvaluatingJavaScriptFromString:js];
}


-(void)logoutFromApp
{    
[self injectJavascript:@"script"];
}

First of all im not even sure that this code is working. How will i know if it has cleared all the cookies.? Meaning, how will i be notified that it has succeeded clearing or not?

Is what im opting to do is the best way of doing this or are there any other methods to give a logout option?

  • 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-08T08:09:07+00:00Added an answer on June 8, 2026 at 8:09 am

    OK i solved the issue..

    #import <Foundation/NSHTTPCookie.h>
    
    
    NSHTTPCookie *aCookie;
    for (aCookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) 
    {
        [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:aCookie];
    }
    

    this deletes all the cookies in the uiwebview. Works great.

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

Sidebar

Related Questions

I'm doing application for iPhone using C sockets. At some point I'm performing recvfrom
I have an iPhone application I've been using for some time that uses ASIHTTPRequest
I am doing a reader application in iPhone which have a loginpage the login
I may be doing an iPhone-based application doing near-real-time sound-processing (filtering, etc). I was
In My iphone Application,I am doing simple image animation in a View and in
I'm doing a check in an iPhone application - int var; if (var !=
I'm currently doing the following as part of my iPhone application NSArray *paths =
Iam doing one application in iphone.In this i need to get the browsing history
I've been trying to get OAuth for Twitter to work on my iPhone application
I'm about to start doing some iPhone application development and it's important to me

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.