How to make persistent Cookies?
For persistent cookies, we need to add an expiration time. In the given code
//Creting a Cookie Object
HttpCookie _userInfoCookies = new HttpCookie("UserInfo");
//Setting values inside it
_userInfoCookies["UserName"] = "Abhijit";
_userInfoCookies["UserColor"] = "Red";
_userInfoCookies["Expire"] = "5 Days";
//Adding Expire Time of cookies
_userInfoCookies.Expires = DateTime.Now.AddDays(5);
//Adding cookies to current web response
Response.Cookies.Add(_userInfoCookies);
Microsoft Technologies,Sap-Modules,Java,IBM-MainFrames,Siebel,Testing,DataBase,PHP, Bpo,Callcenter and Freshers Interview Questions.
Subscribe to:
Post Comments (Atom)
hi ,
ReplyDeletethank you very much