Exemplo n.º 1
0
        public void changeLanguage(object sender, EventArgs e)
        {
            // set cookie that is to be used by Global.asax
            HttpCookie cookie = new HttpCookie("CultureInfo");

            cookie.Value = dllLanguage.SelectedValue;
            Response.Cookies.Add(cookie);


            // set the culture and reload the page for immediate effect
            // Future effects are handled by global.asax

            if (cookie.Equals("auto"))
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(HttpContext.Current.Request.UserLanguages[0].Trim());
                Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(HttpContext.Current.Request.UserLanguages[0].Trim());
            }
            else
            {
                Thread.CurrentThread.CurrentCulture   = new CultureInfo(dllLanguage.SelectedValue, false);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(dllLanguage.SelectedValue, false);
            }

            String a = Request.Path;
            // Server.Transfer(Request.Path);
            string language = Thread.CurrentThread.CurrentCulture.Name;

            // Update session language
            Session["language"] = language;
            Response.Redirect(Page.Request.Url.ToString());
        }
Exemplo n.º 2
0
        public static string GetCookieValue(string cookieName)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[cookieName];

            if (HttpCookie.Equals(cookie, null))
            {
                return(null);
            }
            else
            {
                return(cookie.Value);
            }
        }
Exemplo n.º 3
0
        public static string GetCookieMemberId()
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies["memberId"];

            if (HttpCookie.Equals(cookie, null))
            {
                return(null);
            }
            else
            {
                return(cookie.Value);
            }
        }
Exemplo n.º 4
0
        public void Write(string identifier, UserCredential credential)
        {
            HttpCookie http_cookie = Request.Cookies[identifier];

            if (http_cookie != null && !http_cookie.Equals(null))
            {
                Response.Cookies.Add(new HttpCookie(identifier, Encrypt(Serialize(credential), credential.Login))
                {
                    Expires = DateTime.Now.AddDays(14)
                });
            }
            else
            {
                Response.Cookies.Set(new HttpCookie(identifier, Encrypt(Serialize(credential), credential.Login))
                {
                    Expires = DateTime.Now.AddDays(14)
                });
            }
        }