SETS A COOKIE (C#)
Use this to store small amounts of information specific to a user on their machine.
Sometimes Cookies are refused, so you must account for this
private void Page_Load(object sender, System.EventArgs e)
{
// Run the first time this page is displayed
if(!IsPostBack)
//If the browser supports cookies
{
// Create a cookie
HttpCookie cookUPrefs = new HttpCookie("UPrefs");
// Add the cookie
Response.Cookies.Add(CookUPrefs);
}
}
GETS A COOKIE (C#)
private void Page_Load(object sender, System.EventArgs e)
{
// Run the first time page is displayed
if(!IsPostBack)
// If the browser supports cookies
if(Request.Browser.Cookies)
// Check if the UPrefs cookie exists
if(Request.Cookies["UPrefs"] != null)
// Save the value of the cookie.
Session["Lang"] = Request.Cookies["UPrefs"].Value;
}