views:

511

answers:

2

i have integrated Fbconnect in LoginViewController.I want to logout the session from another view controller .. How i can do this ?

I tried this ..

LoginViewController *obj1 = [[LoginViewController alloc] init];     
[obj1._session logout];
[obj1._session.delegates removeObject: self];

It removing the session..But wen i go to LoginViewController the button is showing logout.But when i quit application and run it, the image is updated.

In LoginViewController i have

@interface LoginViewController : UIViewController  <FBDialogDelegate, FBSessionDelegate, FBRequestDelegate>{

    IBOutlet UITextField *txtUsername;
    IBOutlet UITextField *txtPassword;
    IBOutlet UILabel *lblMessage;
    IBOutlet FBLoginButton* _loginButton;
    FBSession* _session;

}

@property (nonatomic, retain) FBSession *_session;

and am synthesizing it @synthesize _session;

....What else i have to do ?

Somebody please help me..am very new to Iphone application and objective c

A: 

Now i found out that when am calling - (void)logout

its checking if (_sessionKey) condition....

my condition giving false when i call from another view controller..so it will o to else part.. so it will call unsave function..

  • (void)logout {

    if (_sessionKey) { NSLog(@"Logout clicked with session key");

    for (id delegate in _delegates) { if ([delegate respondsToSelector:@selector(session:willLogout:)]) { [delegate session:self willLogout:_uid]; } }

    // Remove cookies that UIWebView may have stored NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage]; NSArray* facebookCookies = [cookies cookiesForURL: [NSURL URLWithString:@"http://login.facebook.com"]]; for (NSHTTPCookie* cookie in facebookCookies) { [cookies deleteCookie:cookie]; }

    _uid = 0; [_sessionKey release]; _sessionKey = nil; [_sessionSecret release]; _sessionSecret = nil; [_expirationDate release]; _expirationDate = nil; [self unsave];

    for (id delegate in _delegates) { if ([delegate respondsToSelector:@selector(sessionDidLogout:)]) { [delegate sessionDidLogout:self]; } } } else { NSLog(@"Logout clicked with out session key");

    [self unsave]; } }

So how i can retain my sessionkey in another viewcontroller ?

any body please answer me....thanks in advance..

Sijo
A: 

I got the answer ..My Friend helped me.. i want to share it...

simply

import "FBConnect.h"

in ur second view controller

then .......

FBSession *session = [FBSession session]; [session logout];

It works fine

Sijo