1

以下のスニペットを使用して、asp に Cookie を設定しています。firebug で自分の Cookie を見ると、Cookie が表示されますが、値自体は空白です。
変数が文字列であることは知っていrespondArray[1]ますが、Cookie に保存されていません。

 System.Web.HttpCookie cookie = new System.Web.HttpCookie("secretKey", respondArray[1]);
 Response.Cookies.Add(cookie);

どんな助けでも大歓迎です。

4

1 に答える 1

1

これを試してみてください

 HttpCookie userCookie = new HttpCookie("UserInfo");  
        userCookie["Country"] = "Italy";  
        userCookie["City"] = "Rome";  
        userCookie["Name"] = "Jones";  


if (cookie != null)   
        {  
            string country = cookie["Country"];  
            string city = cookie["City"];  
            string name = cookie["Name"];  
            Label2.Text = "Cookie Found and read<br/>";  
            Label2.Text += "Name: " + name;  
            Label2.Text += "<br />Country: " + country;  
            Label2.Text += "<br />City: " + city;  
        } 
于 2013-04-04T11:12:07.803 に答える