hi,

ihave this code in c# for crating cookies :

if (saveInCokies_CheckBox.Checked)
{
HttpCookie myCookie = new HttpCookie("AtterehWebCookies");
myCookie["userName"] = userName_TextBox.Text.Trim();
myCookie["password"] = password_TextBox.Text.Trim();
if(employee_RadioButton.Checked)
myCookie["loginType"] = "employee";
else if(lawyer_RadioButton.Checked)
myCookie["loginType"] = "lawyer";
else if(customer_RadioButton.Checked)
myCookie["loginType"] = "customer";


Response.Cookies.Clear();
Response.Cookies.Add(myCookie);
Response.Cookies["AtterehWebCookies"].Expires = DateTime.Now.AddDays(30);


}

after that i want to read that cookies then iused this code:

if (Request.Cookies["AtterehWebCookies"] != null)
{
if (Request.Cookies["AtterehWebCookies"]["userName"] != null &
Request.Cookies["AtterehWebCookies"]["password"] != null &
Request.Cookies["AtterehWebCookies"]["loginType"] != null)
{
userName_TextBox.Text = Request.Cookies["AtterehWebCookies"]["userName"];
password_TextBox.Text = Request.Cookies["AtterehWebCookies"]["password"];


if (Request.Cookies["AtterehWebCookies"]["loginType"].Equals("employee"))
{
employee_RadioButton.Checked = true;
lawyer_RadioButton.Checked = false;
customer_RadioButton.Checked = false;
}
else if (Request.Cookies["AtterehWebCookies"]["loginType"].Equals("lawyer"))
{
lawyer_RadioButton.Checked = true;
employee_RadioButton.Checked = false;
customer_RadioButton.Checked = false;
}
else if (Request.Cookies["AtterehWebCookies"]["loginType"].Equals("customer"))
{
customer_RadioButton.Checked = true;
lawyer_RadioButton.Checked = false;
employee_RadioButton.Checked = false;
}
login_Button_Click(sender, e);
}
}

this two codes worked will for period of time but after that they does not worke and always give me Request.Cookies["AtterehWebCookies"] != null

any one can helpe me plz i thik that after 30 days the cookies are Expired what should i to do to let it worke again

If server side the cookies only valid 30 days, you would need to make them go through the process to generate a new valid one

If server side the cookies only valid 30 days, you would need to make them go through the process to generate a new valid one

hi ,

how can i make them go through the process

Well.. Generally the cookies created when they login, so you'd probably have to log them in. I dont know - ask the owner of the site

Well.. Generally the cookies created when they login, so you'd probably have to log them in. I dont know - ask the owner of the site

i did that but it does not worke i have removed the expire code and changed the cookies file name but it does not worke

most cookies have a default expirey.. Any currently set cookie will keep its old expirey by default too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.