i use cookie utility where i create delete and read my cookie
this is my code
public static void CreateCookie(string CookieName, string[] keys, string[] values, bool Expired, HttpResponse res)
{
HttpCookie c = new HttpCookie(CookieName);
if (keys != null)
{
for (int x = 0; x < keys.Length; x++)
c.Values.Add(keys[x], values[x]);
if (!Expired)
c.Expires = DateTime.Now.AddDays(2);
}
else
c.Expires = DateTime.Now.AddDays(-2);
res.Cookies.Add(c);
}
public static string ReadFromCookie(string CookieName, string key, HttpRequest req)
{
try
{
return req.Cookies[CookieName][key].ToString();
}
catch
{
return null;
}
}
public static void RemoveCookie(string CookieName, HttpResponse res)
{
CreateCookie(CookieName, null, null, false, res);
}
in my login page i create cookie by this code
protected void btnLogin_Click(object sender, EventArgs e)
{
Member m = new Member();
if (m.Login(Txtuser.Text, Txtpass.Text))
{
utility.CreateCookie("login", new string[] { "user", "pass" }, new string[] { Txtuser.Text, Txtpass.Text }, ChkReM.Checked, Response);
Redirect(Txtuser.Text);
}
else
lblmsg.Text = "Username/password incorrect";
}
private void Redirect(string user)
{
if (user == "Admin")
Response.Redirect("Admin/Admin.aspx");
else
{
Response.Redirect("Users/UserInfo.aspx");
}
}
alaaPosted Jul 22, 2013, 6:48 PM
http://rollercoasters-bunker.blogspot.com/2008/07/secureencrypted-cookies-in-aspnet-with.html
http://martijnvanschie.blogspot.in/2009/07/encrypted-cookies-using-aspnet.html
alaaPosted Jul 22, 2013, 10:18 AM
http://www.c-sharpcorner.com/UploadFile/manishkdwivedi/encrypting-and-decrypting-cookies-in-Asp-Net-2-0/
does it also use the same code/class in ASP.NET 4.0 or 4.5?
i read some comments that itisnt support !!!!
Iftikar HussainPosted Jul 22, 2013, 10:01 AM
Regards,
Iftikar
alaaPosted Jul 22, 2013, 9:58 AM
*********************************
http://www.c-sharpcorner.com/UploadFile/manishkdwivedi/encrypting-and-decrypting-cookies-in-Asp-Net-2-0/
does it also use the same code/class in ASP.NET 4.0 or 4.5?
Deepak VermaPosted Jul 22, 2013, 9:51 AM
http://www.c-sharpcorner.com/UploadFile/manishkdwivedi/encrypting-and-decrypting-cookies-in-Asp-Net-2-0/
Iftikar HussainPosted Jul 22, 2013, 9:43 AM
Regards,
Iftikar
alaaPosted Jul 22, 2013, 9:41 AM
Iftikar HussainPosted Jul 22, 2013, 6:13 AM
Regards,
Iftikar
Iftikar HussainPosted Jul 22, 2013, 6:12 AM
Regards,
Iftikar
alaaPosted Jul 22, 2013, 6:08 AM
this is my code
protected void btnLogin_Click(object sender, EventArgs e)
{
Member m = new Member();
if (m.Login(Txtuser.Text, Txtpass.Text))
{
CookieUtil.SetTripleDESEncryptedCookie("login", Txtuser.Text, DateTime.Now.AddDays(2));
Redirect(Txtuser.Text);
}
else
lblmsg.Text = "Username/password incorrect";
}
private void Redirect(string user)
{
Response.Redirect("Users/UserInfo.aspx?=n "+Txtusername.Text+"&g="+txtpass.Text");
}
}
it appears the value not encrypt despite the value is really encrypt
Iftikar HussainPosted Jul 21, 2013, 11:14 PM
Regards,
Iftikar
alaaPosted Jul 21, 2013, 9:35 AM
Iftikar HussainPosted Jul 21, 2013, 12:33 AM
Please refer the below link
http://martijnvanschie.blogspot.in/2009/07/encrypted-cookies-using-aspnet.html
Regards,
Iftikar
Sanjeeb LenkaPosted Jul 20, 2013, 3:03 PM
http://rollercoasters-bunker.blogspot.in/2008/07/secureencrypted-cookies-in-aspnet-with.html
http://www.c-sharpcorner.com/UploadFile/manishkdwivedi/encrypting-and-decrypting-cookies-in-Asp-Net-2-0/