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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:33:18+00:00 2026-06-04T04:33:18+00:00

I have used Facebook Connect on another project with relatively few problems, however on

  • 0

I have used Facebook Connect on another project with relatively few problems, however on my current project it seems that when I call [facebook logout]; it doesn’t remove the users details. If I then restart the app, I have the following in the didFinishLaunchingWithOptions function:

facebook = [[Facebook alloc] initWithAppId:@"XXXXXXXXXXXXX" andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

if([defaults objectForKey:@"FBAccessTokenKey"]
   && [defaults objectForKey:@"FBExpirationDateKey"]){
    facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
    facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];

}

    NSLog(@"startup login");
    [self loginToFacebook];//attempt to login automatically on startup

My loginToFacebook function is this:

- (void)loginToFacebook
{
    NSLog(@"Logging into facebook");
    //set up facebook and login in automatically if possible
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    if([defaults objectForKey:@"FBAccessTokenKey"]
       && [defaults objectForKey:@"FBExpirationDateKey"]){
        facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];

    }

    if (![facebook isSessionValid]){

        //get permissions that user will need to agree to us using
        NSArray *permissions = [[NSArray alloc] initWithObjects:
                                @"user_likes",@"read_friendlists",@"offline_access", @"publish_stream",
                            nil];
        //authorise our login
        [facebook authorize:permissions];
        [permissions release];
    }
    else
    {
        [facebook authorize:nil];
    }
}

As far as I am concerned, this time I should be prompted to login with my email and password.
I am mostly using the simulator so the Facebook app itself is not the cause, and in the Facebook.h class I have changed

[self authorizeWithFBAppAuth:NO safariAuth:YES];

to

[self authorizeWithFBAppAuth:NO safariAuth:NO];

However what happens is that the facebook window briefly flashes up and disappears, as I would expect it to when I am already logged in. It then loads my id, name, friends list etc from my previous login details. It’s no longer possible for me to change users! I should add that I have the following code which prints accordingly on ‘logout’:

- (void)fbDidLogout{
    NSLog(@"Logged out of facebook");
}

…which prints to the console when [facebook logout] is called. I also have the correct url schemes in place so there is no problem there.

As I say I’ve got this working on another app, but I can’t see what I could’ve overlooked this time.
I welcome any suggestion, as I suspect it’s something ridiculously simple.

Edit: I’ve just tested it out on a device, and the attempt to login to Facebook causes the app to crash. I suspect it’s because it’s attempting to login using ‘stored’ info, which doesn’t exist because I haven’t logged in on the device yet. I’m still investigating but again, if any can see an obvious flaw I’d be very grateful.

Edit2:I’ve tried removing cookies using safecase’s example. I also print out all of the cookies during a) didFinishLaunchingWithOptions and b) during fbDidLogout, and I get the following:

a)
`2012-05-18 10:40:40.665 MyApp[15545:17003] (
“”,

"<NSHTTPCookie version:0 name:\"c_user\" value:\"634361620\" expiresDate:2012-06-17 09:34:33 +0000 created:2012-05-18 09:34:34 +0000 (3.59026e+08) sessionOnly:FALSE domain:\".facebook.com\" path:\"/\" isSecure:TRUE>",
"<NSHTTPCookie version:0 name:\"csm\" value:\"2\" expiresDate:2012-06-17 09:34:33 +0000 created:2012-05-18 09:34:34 +0000 (3.59026e+08) sessionOnly:FALSE domain:\".facebook.com\" path:\"/\" isSecure:FALSE>",
"<NSHTTPCookie version:0 name:\"datr\" value:\"gxe2T8ZyBzMGb5w3LS29Q0kJ\" expiresDate:2014-05-18 09:34:33 +0000 created:2012-05-18 09:34:34 +0000 (3.59026e+08) sessionOnly:FALSE domain:\".facebook.com\" path:\"/\" isSecure:FALSE>",
"<NSHTTPCookie version:0 name:\"locale\" value:\"en_US\" expiresDate:2012-05-25 09:36:43 +0000 created:2012-05-18 09:36:44 +0000 (3.59027e+08) sessionOnly:FALSE domain:\".facebook.com\" path:\"/\" isSecure:FALSE>",
"<NSHTTPCookie version:0 name:\"lu\" value:\"RgayA7CMIlsAl-lOD2-Y-O3g\" expiresDate:2014-05-18 09:34:33 +0000 created:2012-05-18 09:34:34 +0000 (3.59026e+08) sessionOnly:FALSE domain:\".facebook.com\" path:\"/\" isSecure:FALSE>",
"<NSHTTPCookie version:0 name:\"m_user\" value:\"0%3A0%3A0%3A0%3Av_1%2Cajax_1%2Cwidth_320%2Cpxr_1%2Cgps_1%3A1337333673%3A2\" expiresDate:2012-08-16 09:34:33 +0000 created:2012-05-18 09:34:34 +0000 (3.59026e+08) sessionOnly:FALSE domain:\".facebook.com\" path:\"/\" isSecure:FALSE>",
"<NSHTTPCookie version:0 name:\"s\" value:\"Aa4WdKU-oOFathmK\" expiresDate:2012-06-17 09:34:33 +0000 created:2012-05-18 09:34:34 +0000 (3.59026e+08) sessionOnly:FALSE domain:\".facebook.com\" path:\"/\" isSecure:TRUE>",
"<NSHTTPCookie version:0 name:\"xs\" value:\"125%3AFFIWXjAXDXUMmw%3A2%3A1337333673\" expiresDate:2012-06-17 09:34:33 +0000 created:2012-05-18 09:34:34 +0000 (3.59026e+08) sessionOnly:FALSE domain:\".facebook.com\" path:\"/\" isSecure:TRUE>"

)`

b)
2012-05-18 10:41:16.530 MyApp[15545:17003] (
)

Since it changes to empty, I would assume they are deleted. But on reopening the app, they are all there again.

Edit3: The only way around this I have found is to delete all cookies as soon as the application opens, however this means the user has to login every time, even if they left themselves logged in the last time they had the app open. It’s a temporary fix for the moment, I’m still not sure why it’s not working as it should be.

  • 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-04T04:33:18+00:00Added an answer on June 4, 2026 at 4:33 am

    You provide this method when user clicks on logout and remove all keys stored in userdefault for facebook

    - (void)fbDidLogout
    {
      NSLog(@"Logged out of facebook");
      NSHTTPCookie *cookie;
       NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
       for (cookie in [storage cookies])
       {
           NSString* domainName = [cookie domain];
           NSRange domainRange = [domainName rangeOfString:@"facebook"];
           if(domainRange.length > 0)
           {
               [storage deleteCookie:cookie];
           }
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used Facebook Connect in my site but it is not working properly.
Below is the code used to connect to the Facebook API, will it have
I've used this code to have a like btn on my site: <iframe src=http://www.facebook.com/plugins/like.php?href=URL_OF_YOUR_WEBSITE&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=80&amp
We have used Infragistics controls in our applications for years. However, we have always
I use the PHP library for Facebook Connect. The library is used as follows:
I am doing my second Facebook connect site. On my first site, I used
I have an iframe tab in facebook. I used overflow:hidden in the body tag
I have used Facebook API to make posts to my wall on Facebook with
I am using facebook connect in one of my website. For this i have
Previously i used the JavaScript API for Facebook Connect, so i had the fb:login-button

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.