| | |
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 angle array barchart bitmap box broadcast c# capturing check checkbox client combobox control conversion convert csharp custom database datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum event excel file firefox form format forms function gdi+ httpwebrequest image index input install java label leak libraries list listbox mandelbrot math monodevelop mouseclick msword mysql operator path pause photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox round server sleep socket sql statistics stream string table tcpclientchannel text textbox thread time timer update usercontrol validation virtualization visualbasic visualstudio webbrowser windows winforms wpf xml






