Parameters
- name
- Cookie Name
- value
- Cookie value
- isEssential
- indicates the cookie is essential default is false
public class ShopController : Controller { private readonly IPageRequest _page; private ILatLongRepository _latLongRepository; public ShopController(IPageRequest page, ILatLongRepository latLongRepository) { _page = page; _latLongRepository = latLongRepository; } public async Task<IActionResult> Index(ShoppingCard data) { int cardId = -1; if (_page.User.TryReadCookie("CredidCardId", out var sValue) && int.TryParse(sValue, out cardId)) { //some magic code } _page.User.WriteCookie("CredidCardId", cardId.ToString(CultureInfo.InvariantCulture)); }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2