0
votes

I have a MVC4, .Net4.5 application where we are using sessions. For no apparent reason, MVC4 is not creating the Session ID Cookie. Below is authentication and sessionstate settings from web.config

<authentication mode="Forms">
  <forms cookieless="UseCookies" loginUrl="~/Login" timeout="480"></forms>
</authentication>
<sessionState timeout="50" cookieless="UseCookies" mode="InProc"/>

It is not an issue with cookies as the Forms Auth cookie is present.

Suggestions?

1
Are you trying to get session cookie by JavaScript?Andrei

1 Answers

6
votes

For no apparent reason, MVC4 is not creating the Session ID Cookie.

Maybe you never stored anything in the session on the server:

Session["foo"] = "bar";

Only then you will see the session cookie being set to the response of this particular request. That's by design. Even if you enable ASP.NET Session on the server the cookie will never be set to the client until a value is stored in the session.