简体   繁体   中英

how to figure out if a facebook user is logged to facebook connect in from C#

I'm trying to figure how whether or not the current user is logged in with their facebook account on my site...

I've tried searching around and looking through the facebook namespace but haven't found anything similar to isUserLoggedIn() .

I'm guessing I missed it somewhere... Anyone know of a method that would work for this?

Check for the session key cookie.

    public static string SessionKey
    {
        get { return GetFacebookCookie("session_key"); }
    }

    private static string GetFacebookCookie(string propertyName)
    {
        var fullName = ApiKey + "_" + propertyName;

        if (HttpContext.Current == null || HttpContext.Current.Request.Cookies[fullName] == null)
            return null;

        return HttpContext.Current.Request != null ? HttpContext.Current.Request.Cookies[fullName].Value : null;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM