private HackathonWebApi.Membership.User SetupFormsAuthTicket(string userName, bool persistanceFlag)
        {
            var usersContext = new UsersContext();
            HackathonWebApi.Membership.User user = usersContext.GetUser(userName);
            var userId = user.UserId;
            var userData = userId.ToString(CultureInfo.InvariantCulture);
            var authTicket = new FormsAuthenticationTicket(1, //version
                                userName, // user name
                                DateTime.Now,             //creation
                                DateTime.Now.AddMinutes(30), //Expiration
                                persistanceFlag, //Persistent
                                userData);

            var encTicket = FormsAuthentication.Encrypt(authTicket);
            var response = Request.CreateResponse(HttpStatusCode.Created);

            //var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);

            //var cookieHeaderValue = new CookieHeaderValue("loginCookie",);

            var cookie = new CookieHeaderValue("session-id", "12345");
            cookie.Cookies.Add(new CookieState(FormsAuthentication.FormsCookieName, encTicket));
            cookie.Expires = DateTimeOffset.Now.AddDays(1);
            cookie.Domain = Request.RequestUri.Host;
            cookie.Path = "/";

            response.Headers.AddCookies(new List<CookieHeaderValue> { cookie });
            return user;
        }
        private HackathonWebApi.Membership.User SetupFormsAuthTicket(string userName, bool persistanceFlag)
        {
            var usersContext = new UsersContext();
            HackathonWebApi.Membership.User user = usersContext.GetUser(userName);
            var userId = user.UserId;
            var userData = userId.ToString(CultureInfo.InvariantCulture);
            var authTicket = new FormsAuthenticationTicket(1, //version
                                userName, // user name
                                DateTime.Now,             //creation
                                DateTime.Now.AddMinutes(30), //Expiration
                                persistanceFlag, //Persistent
                                userData);

            var encTicket = FormsAuthentication.Encrypt(authTicket);
            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
            return user;
        }