当我按下facebook注销按钮时(当我登录时会自动显示,因为我正在使用autologutlink属性)
<fb:login-button autologoutlink="true"></fb:login-button>
我还有五个Facebook Cookies:
八哥
MyApiKey_会话密钥
MyApiKey_过期
MyApiKey_用户
在我注销之后,我真的在Facebook上注销了,因为我需要再次登录Facebook.com,但是
isConnected()
var connectSession = new ConnectSession(ConfigurationManager.AppSettings["ApiKey"], ConfigurationManager.AppSettings["Secret"]);
if (connectSession.IsConnected())
{
var api = new Api(connectSession);
filterContext.Controller.ViewData["FBUser"] = api.Users.GetInfo();
}
首先,我不明白为什么我还可以检索用户信息,即使我不再登录,其次:我如何删除这个Cookies。以下代码不起作用:
public static void ClearFacebookCookies()
{
String[] shortNames = new String[] { "_user", "_session_key", "_expires", "_ss", "" };
HttpContext currentContext = HttpContext.Current;
if (currentContext == null)
{
return;
}
string appKey = ConfigurationManager.AppSettings["APIKey"];
if (appKey == null)
{
throw new Exception("APIKey is not defined in web.config");
}
foreach (var name in shortNames)
{
string fullName = appKey + name;
HttpCookie cookie = currentContext.Response.Cookies[fullName];
if (cookie != null)
{
cookie.Value = null;
cookie.Expires= DateTime.Now.AddDays(-1d);
}
HttpCookie cookieRequest = currentContext.Request.Cookies[fullName];
if (cookieRequest != null)
{
cookieRequest.Value = null;
cookieRequest.Expires = DateTime.Now.AddDays(-1d);
}
}
}// end Method