dimanche 25 juin 2017

Checking Cookie for the duplicate value

I want to check for the duplication in the cookie before new data is being added. I have used | operator to separate 2 items from each other. Each item consist of name, picture, price, and address. I dont want user to pick the same element again. Kindly help me out with this. P.S i am working on a course project using ASP as a server side language. This is my code for the cookies.

if (Request.Cookies["aa"] == null)
            {
                Response.Cookies["aa"].Value = Name.ToString() + "," + Address.ToString() + "," + Picture.ToString() + "," + Price.ToString();
                Response.Cookies["aa"].Expires = DateTime.Now.AddDays(1);
            }

            else
            {

                Response.Cookies["aa"].Value = Request.Cookies["aa"].Value + "|" + Name.ToString() + "," + Address.ToString() + "," + Picture.ToString() + "," + Price.ToString();
                Response.Cookies["aa"].Expires = DateTime.Now.AddDays(1);
            }  




Aucun commentaire:

Enregistrer un commentaire