User remains logged in after logout

Dec 15, 2007 at 12:34 PM
I am using the facebook api v:1.0 and i have strange problem. When user logs off from the facebook and then logs in immediatley with some other user id in same browser window, the application consider him as previous user.
Following is the code that I use for user authentication
public static bool CheckLogin()
{
string sessionKey = HttpContext.Current.Session"facebook_session_key" as String;
string userId = HttpContext.Current.Session"facebook_userId" as String;
string authToken = HttpContext.Current.Request.QueryString"auth_token";

if (!String.IsNullOrEmpty(sessionKey))
{
_fbService.SessionKey = sessionKey;
_fbService.UserId = userId;
return true;
}
else if (!String.IsNullOrEmpty(authToken))
{
_fbService.CreateSession(authToken);
HttpContext.Current.Session"facebook_session_key" = _fbService.SessionKey;
HttpContext.Current.Session"facebook_userId" = _fbService.UserId;
HttpContext.Current.Session"facebook_session_expires" = _fbService.SessionExpires;
return true;
}
else
{
HttpContext.Current.Response.Redirect(@"http://www.facebook.com/login.php?api_key=" +
ApplicationKey + @"&v=1.0", false);
return false;
}
}

If i call the GetLoggedInUser(), It also returns the ID of logged out user.
I am developing the application for IFrame.
If someone faced this problem and have the solution, please help me. Its very urgent

Thanx in advance
Dec 29, 2007 at 1:33 AM
Im facing the same problem mate and could not find a solution yet..
Jan 2, 2008 at 2:58 AM

I highly recommend you go with the inbuilt "free" code from the Toolkit... e.g.

public partial class YourClassName : CanvasIFrameBasePage
{
new protected void Page_Load(object sender,
EventArgs eventArgs)
{
base.Api = this.Master.Api;
base.Secret = this.Master.Secret;
base.Page_Load(sender, eventArgs);
}
}


...doing that hooks you in and handles all your connections and everything for you. You'll find your FacebookService object in the base as "FBService" (i.e. base.FBService)... done!



fiqbal81 wrote:
I am using the facebook api v:1.0 and i have strange problem. When user logs off from the facebook and then logs in immediatley with some other user id in same browser window, the application consider him as previous user.
Following is the code that I use for user authentication
public static bool CheckLogin()
{
string sessionKey = HttpContext.Current.Session"facebook_session_key" as String;
string userId = HttpContext.Current.Session"facebook_userId" as String;
string authToken = HttpContext.Current.Request.QueryString"auth_token";

if (!String.IsNullOrEmpty(sessionKey))
{
_fbService.SessionKey = sessionKey;
_fbService.UserId = userId;
return true;
}
else if (!String.IsNullOrEmpty(authToken))
{
_fbService.CreateSession(authToken);
HttpContext.Current.Session"facebook_session_key" = _fbService.SessionKey;
HttpContext.Current.Session"facebook_userId" = _fbService.UserId;
HttpContext.Current.Session"facebook_session_expires" = _fbService.SessionExpires;
return true;
}
else
{
HttpContext.Current.Response.Redirect(@"http://www.facebook.com/login.php?api_key=" +
ApplicationKey + @"&v=1.0", false);
return false;
}
}

If i call the GetLoggedInUser(), It also returns the ID of logged out user.
I am developing the application for IFrame.
If someone faced this problem and have the solution, please help me. Its very urgent

Thanx in advance