Reading cookie in c#

后端 未结 7 937
心在旅途
心在旅途 2020-12-19 07:47

I want someone who visits my internationalized site to be able to change the language. I thought best way would be to store the language chosen in a cookie - so when the pag

相关标签:
7条回答
  • 2020-12-19 08:42

    To set cookies value:

    HttpCookie Userinfo= new HttpCookie("Userinfo");
    Userinfo["Username"] = application.username.ToString();
    Response.Cookies.Add(Userinfo);
    

    To get cookies value:

    HttpCookie reqUserinfocookies = Request.Cookies["Userinfo"];
    if (reqUserinfocookies != null)
    {
    string username = reqUserinfocookies["username"];
    }
    
    0 讨论(0)
提交回复
热议问题