2
Answers

cookies not passing the values from one page to another page

vipin saini

vipin saini

14y
2.8k
1

hi,
In my application cookies not passing values one page to another page after uploading the web server but on local server it is working properly.
i use for adding cookies
HttpCookie cookie = new HttpCookie("Preferences");
cookie[
"Location"] = DropDownList1.SelectedValue;
cookie[
"Range"] = DropDownList2.SelectedValue;
cookie[
"Roomtype"] = DropDownList3.SelectedValue;
cookie[
"rooms"] = DropDownList4.SelectedValue;
cookie[
"Adult"] = DropDownList5.SelectedValue;
cookie[
"Children"] = DropDownList6.SelectedValue;
cookie[
"checkin"] = TextBox1.Text;
cookie[
"checkout"] = TextBox2.Text;
Response.Cookies.Add(cookie);
and for retriving
HttpCookie cookie = Request.Cookies["Preferences"];
if (cookie != null)
{
a = cookie[
"Location"];
b = cookie[
"Range"];
c = cookie[
"Roomtype"];
d = cookie[
"rooms"];
i = cookie[
"Adult"];
i1 = cookie[
"Children"];
 
g = cookie[
"checkin"];
h = cookie[
"checkout"];
}
Answers (2)