Using C# With Cookies | ||
| ||
| /* Read shopper id from client cookie */ public static bool GetCurrentShopperId(ref string id,System.Web.HttpRequest request) { try{ HttpCookie cookie = request.Cookies["iparts_pa"]; if (cookie == null){ //cookie not found id = string.Empty; return false; } else{ //cookie ok id = cookie.Values["shopperid"].ToString(); //cookie empty or not return id.Trim().Length > 0; } } catch(Exception e){ string s = e.ToString(); //to get rid of compiler warning return false; } } /* Write the shopper id to a client cookie */ public static bool SetCurrentShopperId(string shopperid,System.Web.HttpResponse response) { HttpCookie cookie = new HttpCookie("iparts_pa"); cookie.Values.Add("shopperid",shopperid); response.Cookies.Add(cookie); return true; } | ||
| | ||
| |