Пример #1
0
        public ActionResult SessionManagement()
        {
            var siteCookie = GetSessionCookie();

            if (siteCookie != null)
            {
                ViewData["session_id"] = siteCookie.Value;
                return(View());
            }
            var sessionId     = _passwordHashProvidcer.Hash(Guid.NewGuid() + _randomNumberGenerator.GenerateLong().ToString(), _salt);
            var custom        = _passwordHashProvidcer.Hash(Guid.NewGuid() + _randomNumberGenerator.Generate().ToString(), _salt);
            var cookieName    = string.Format("{0}{1}", SessionCookieNamePrefix, custom);
            var sessionCookie = new HttpCookie(cookieName)
            {
                Value  = sessionId,
                Domain = Request.Url.Host,
                Path   = "~/good/",
                // Expires = End of the session,
                HttpOnly  = true,
                Shareable = false
            };

            Response.Cookies.Add(sessionCookie);
            ViewData["session_id"] = sessionId;
            return(View());
        }