6

I have a project build on Asp.net MVC 4 and in our application we need to make the session cookie secure.

I have tried this code to make my cookie secure.

var encryptedTicket = FormsAuthentication.Encrypt(authenticationTicket);
httpContext.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket) { Secure = true, HttpOnly = true });

Also in webconfig file

<httpCookies httpOnlyCookies="true" requireSSL="true" />

The issue is when I am using HttpOnly = true, application is able to create the cookie successfully.

But when I tried also with secure = true, cookie was not created and user never gets logged in.

After login enter image description here Can somebody please help where i am getting wrong.

Thanks in advance.

Rahul lamba
  • 131
  • 7

0 Answers0