Skip to main content

Posts

Showing posts with the label How to create cookies in asp net mvc and read in JavaScript

How to create cookies in asp net mvc and read in JavaScript

Create cookies using MVC 5 controller code-sample ? 1 2 3 4 5 6 7 private static void CreateCookies( string UID) {       System.Web.HttpCookie cookie =   System.Web.HttpContext.Current.Request.Cookies[ "UIDCookie" ] ??       new System.Web.HttpCookie( "UIDCookie" );       cookie.Values[ "UID" ] = Convert.ToString(UID);               System.Web.HttpContext.Current.Response.Cookies.Add(cookie); } private static void CreateCookies(string UID) { System.Web.HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies["UIDCookie"] ?? new System.Web.HttpCookie("UIDCookie"); cookie.Values["UID"] = Convert.ToString(UID); System.Web.HttpContext.Current.Response.Cookies.Add(cookie); } Read cookies using JavaScript code-sample ? 01 02 03 04 05 06 ...