public IActionResult Index() { HttpContext.Session.SetString("SessionName", "Laiman"); var SessionName = HttpContext.Session.GetString("SessionName"); ViewBag.device = _detectionService.Device.Type; ViewBag.browser = _detectionService.Browser.Name; ViewBag.platform = _detectionService.Platform.Name; ViewBag.engine = _detectionService.Engine.Name; var visitor_ip = _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(); ViewBag.ip = functions.FormatVisitorIP(visitor_ip); ViewBag.country = functions.GetIpInfo("188.130.155.151", "Country"); ViewBag.session = SessionName; string product_id = "9DG52SMLA21F"; //Get current ViewedProducts session var ViewedProducts = (HttpContext.Session.GetString("ViewedProducts") != null) ? HttpContext.Session.GetString("ViewedProducts") : ""; //if not viewed already if (!functions.IsProductViewed(product_id, ViewedProducts)) { //if not null set to session data else set to empty HttpContext.Session.SetString("ViewedProducts", ViewedProducts + ",product_id_" + product_id.ToString()); ViewBag.view = "Logged View"; } else { ViewBag.view = "Not Logged"; } ViewBag.cartData = HttpContext.Session.GetString("ShoppingCart"); return(View(_detectionService)); }