| | |
C# and Cookies problem
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Dec 2007
Posts: 41
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Dec 2007
Posts: 41
Reputation:
Solved Threads: 0
Last edited by IT_Techno; Dec 3rd, 2008 at 9:28 am.
![]() |
Similar Threads
- IE6 Enable Cookies problem (Web Browsers)
- Cookies Problem (Windows NT / 2000 / XP)
- Hotmail "error on page" problem (Web Browsers)
- CommonNames problem (Web Browsers)
- ...Not sure where the problem lies... (Web Browsers)
- internet explorer problem (aaaaaaarrrrrrgggggh) (Web Browsers)
- Ie6.. A coomon problem I tihnk (Web Browsers)
- keep getting booted from ID to Guest! (DaniWeb Community Feedback)
Other Threads in the C# Forum
- Previous Thread: decimal places & asterisk help
- Next Thread: image in listView
| Thread Tools | Search this Thread |
.net access algorithm animation array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom customactiondata database datagrid datagridview dataset datastructure date/time datetime datetimepicker degrees development dll draganddrop drawing encryption enum event excel file filename files form format forms function gdi+ gis gtk hash image index input install java label list listbox mandelbrot math mouseclick mysql operator outlook2003 path photoshop picturebox pixelinversion pixelminversion post programming radians regex remoting richtextbox server sleep snooze socket sql statistics stream string table tables tcp text textbox thread time timer update usercontrol usercontrols validation visualstudio webbrowser webcam wia windows winforms wpf xml






