Cookies值不安全

时间:2019-04-09 19:33:00

标签: c# asp.net cookies

问题:

我正在尝试将多个变量保存在1个cookie中,但是cookie不保存值。因为当我转到另一个页面时,cookie是安全的。变量不是空的,我检查过,并且在调试时也将值放在cookie中,就像我说的那样,它不保存

代码:

string omschrijving = GridView1.Rows[0].Cells[0].Text.ToString();
string   Productnaam = GridView1.Rows[0].Cells[1].Text.ToString();
string  Maat = GridView1.Rows[0].Cells[2].Text.ToString();
string  Voorraad = GridView1.Rows[0].Cells[3].Text.ToString();
string  groepnaam = GridView1.Rows[0].Cells[4].Text.ToString();
string  prijs = GridView1.Rows[0].Cells[5].Text.ToString();

SqlConnection cnn = new SqlConnection(Global.sqlcnn);
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;           
cmd.CommandText = "SELECT Afbeelding FROM TblProducten where Productnaam = '" + Productnaam + "'";
cnn.Open();
Afbeelding = cmd.ExecuteScalar().ToString();
cnn.Close();

if (Request.Cookies["aa"] == null)
 {
   Response.Cookies["aa"].Value = omschrijving + "," + Productnaam + "," + Maat + "," + Voorraad + "," + Afbeelding + "," + groepnaam + "," + prijs;
                Response.Cookies["aa"].Expires = DateTime.Now.AddDays(10);
       }
  else
   {
                Response.Cookies["aa"].Value = Request.Cookies["aa"].Value + "|" + omschrijving + " ," + Productnaam + " ," + Maat + " ," + Voorraad + " ," + Afbeelding + " ," + groepnaam + " ," + prijs;
                Response.Cookies["aa"].Expires = DateTime.Now.AddDays(10);
         }

任何人都难以理解为什么cookie无法保存?

0 个答案:

没有答案