How to store store username and password using javascript in asp.net.
how to store store username and password in cookie using javascript in asp.net.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Posted Jul 9, 2012, 3:45 AM EDT
Create a cookie object and add it into the Responce.Cookies collection.
[code]
HttpCookie userCookie = new HttpCookie("UserInformation");
userCookie["UserName"] = "username";
userCookie["Password"] = "password";
userCookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(userCookie);
From Javascript.
[code]
function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString();
}
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 9, 2012, 3:46 AM EDT
Please refer the below links
http://eisabainyo.net/weblog/2009/02/20/store-login-information-in-cookie-using-jquery/
http://stackoverflow.com/questions/8508999/trying-to-save-username-password-in-cookie-jquery
Thanks