Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing multiple cookies in one web application
    text
    copied!<p>I want to use cookies in my web application. My web application is a portal that accepts modules (some thing like dot net nuke). Now in my core I used cookies to store user language :</p> <pre><code>protected void Application_BeginRequest(object sender, EventArgs e) { if (Request.Cookies["IPortalCookies"] == null) { using (var context = new EasyToUseEntities()) { try { var lang = (from l in context.Core_Settings orderby l.SiteID descending select l).FirstOrDefault(); if (lang != null) { Response.Cookies["IPortalCookies"]["Language"] = lang.DefaultLanguage; Response.Cookies["IPortalCookies"]["Direction"] = lang.DefaltDirection; Response.Cookies["IPortalCookies"].Expires = DateTime.Now.AddYears(1); } else { Response.Cookies["IPortalCookies"]["Language"] = "en"; Response.Cookies["IPortalCookies"]["Direction"] = "ltr"; Response.Cookies["IPortalCookies"].Expires = DateTime.Now.AddYears(1); } } catch (Exception) { Response.Cookies["IPortalCookies"]["Language"] = "en"; Response.Cookies["IPortalCookies"]["Direction"] = "ltr"; Response.Cookies["IPortalCookies"].Expires = DateTime.Now.AddYears(1); } } } Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request.Cookies["IPortalCookies"]["Language"]); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.Cookies["IPortalCookies"]["Language"]); } </code></pre> <p>In one module I used cookies to store user visits, so the problem: When I install that module and cookie works, for first time it works fine, but when I am trying reload page or change page or any thing else it shows <code>null reference error</code>!</p> <pre><code>if (Request.Cookies["IPortalCookies"] != null) { if (Request.Cookies["IPortalCookies"]["Likes"] == null || Request.Cookies["IPortalCookies"]["Likes"].Contains("'" + articleid + "'") == false) { if (_ah.LikeIt(articleid)) { Response.Cookies["IPortalCookies"]["Likes"] = Request.Cookies["IPortalCookies"]["Likes"] + ",'" + articleid + "'"; BindRepeater(); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload