TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
alaa
NA
166
85.7k
encrypting and decrypting cookies asp.net
Jul 20 2013 8:16 AM
hi i wanna to know how can i encrypting and decrypting cookies asp.net
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");
}
}
how can i encrypting and decrypting my cookies in this code
Reply
Answers (
14
)
'no printers installed ' error in my web application
SQL Select query of more than one value of a same Attribute