Пример #1
0
        public static void SetConnectionString(string Conn)
        {
            HttpCookie aCookie = new HttpCookie("DCS");

            aCookie.Value    = AESStringCrypto.Encrypt(Conn, passPhrase);
            aCookie.Expires  = DateTime.Now.AddYears(1);
            aCookie.Domain   = "localhost";
            aCookie.Secure   = true;
            aCookie.HttpOnly = false;
            System.Web.HttpContext.Current.Response.Cookies.Add(aCookie);
        }
Пример #2
0
        public static void SetUserPreferences(int SId, int DId)
        {
            HttpCookie aCookie = new HttpCookie("UserPref");

            aCookie.Values["SId"] = AESStringCrypto.Encrypt(SId.ToString(), passPhrase);
            aCookie.Values["DId"] = AESStringCrypto.Encrypt(DId.ToString(), passPhrase);
            aCookie.Expires       = DateTime.Now.AddYears(1);
            aCookie.Domain        = "localhost";
            aCookie.Secure        = true;
            aCookie.HttpOnly      = false;
            System.Web.HttpContext.Current.Response.Cookies.Add(aCookie);
        }
Пример #3
0
 public static UserPreferences GetUserPreferences()
 {
     if (System.Web.HttpContext.Current.Request.Cookies["UserPref"] != null)
     {
         var             Cookie = System.Web.HttpContext.Current.Request.Cookies["UserPref"].Values;
         UserPreferences upObj  = new UserPreferences();
         upObj.SiteId     = Convert.ToInt32(AESStringCrypto.Decrypt(Cookie["SId"], passPhrase));
         upObj.DivisionId = Convert.ToInt32(AESStringCrypto.Decrypt(Cookie["DId"], passPhrase));
         return(upObj);
     }
     else
     {
         return(null);
     }
 }
Пример #4
0
        public static string GetConnectionString()
        {
            if (System.Web.HttpContext.Current.Request.Cookies["DCS"] != null)
            {
                string Ct = (string)System.Web.HttpContext.Current.Request.Cookies["DCS"].Value;

                string Pt = AESStringCrypto.Decrypt(Ct, passPhrase);

                return(Pt);
            }
            else
            {
                return(string.Empty);
            }
        }