Exemplo n.º 1
0
        /// <summary>
        /// Checks if sessionId and token cookies are still valid.
        /// Sets cookie flag if they are invalid.
        /// </summary>
        /// <returns>true if cookies are valid; otherwise false</returns>
        bool CheckCookies()
        {
            // We still haven't re-authenticated
            if (cookiesAreInvalid)
            {
                return(false);
            }

            try
            {
                if (!SteamWeb.VerifyCookies())
                {
                    // Cookies are no longer valid
                    Log.Warn("Cookies are invalid. Need to re-authenticate.");
                    cookiesAreInvalid = true;
                    SteamUser.RequestWebAPIUserNonce();
                    return(false);
                }
            }
            catch
            {
                // Even if exception is caught, we should still continue.
                Log.Warn("Cookie check failed. http://steamcommunity.com is possibly down.");
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks if sessionId and token cookies are still valid.
        /// Sets cookie flag if they are invalid.
        /// </summary>
        /// <returns>true if cookies are valid; otherwise false</returns>
        bool CheckCookies()
        {
            // We still haven't re-authenticated
            if (CookiesAreInvalid)
            {
                return(false);
            }

            // Construct cookie container
            CookieContainer cookies = new CookieContainer();

            cookies.Add(new Cookie("sessionid", sessionId, String.Empty, "steamcommunity.com"));
            cookies.Add(new Cookie("steamLogin", token, String.Empty, "steamcommunity.com"));

            try
            {
                if (!SteamWeb.VerifyCookies(cookies))
                {
                    // Cookies are no longer valid
                    log.Warn("Cookies are invalid. Need to re-authenticate.");
                    CookiesAreInvalid = true;
                    SteamUser.RequestWebAPIUserNonce();
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch
            {
                // Even if exception is caught, we should still continue.
                log.Warn("Cookie check failed. http://steamcommunity.com is possibly down.");
                return(true);
            }
        }