1

I have the following in my controller:

    public ActionResult Login(string email, string password)
    {
        /* 
           some stuff 
           ...
        */
        HttpCookie CustomerCookie = new HttpCookie("Customer");
        CustomerCookie.Values.Add("FirstName", Customer.FirstName);
        CustomerCookie.Values.Add("LastName", Customer.LastName);
        CustomerCookie.Values.Add("Email", email);
        CustomerCookie.Secure = true;
        Response.Cookies.Add(CustomerCookie);
        return RedirectToAction("OrderType", "Order");
    }

But for some reason when I look for the cookie it is nowhere to be found after the redirect. Based on this question I was assuming that the method above would work.

Can anyone see why my cookie is not being created here?

Community
  • 1
  • 1
Abe Miessler
  • 82,532
  • 99
  • 305
  • 486

1 Answers1

2

Some troubleshooting steps I would take:

  • Remove the redirect and just return an empty view and see if the cookie is there
  • Do not set Secure to true and see if that's the issue
  • Force a response flush to see if there's an action filter or something post action execution that's preventing the cookie from being returned in the response
  • Use fiddler to look at the actual http response for the cookie in case your browser is preventing cookies
Kristofor
  • 58
  • 10
  • 1
    Gah - it was totally the secure flag! I forgot that I'm not using a secure connection when I run locally. Thanks! – Abe Miessler Jul 16 '15 at 21:53