When using cookie authentication in ASP.NET MVC, after calling PasswordSignInAsync
to log the user in, a cookie with encrypted session information is stored for future requests. By default this is named .AspNet.ApplicationCookie
. Is there a way to get the value of that cookie immediately after signing the user in, before leaving the method that it was called from?
I've inspected Response.Cookies
after successful sign in, but it doesn't contain any values and I can't figure out when that cookie is actually being set.
No, you can't get the value of that cookie in the same request as where the cookie is set - the setting is delayed until very late, when the reply is actually sent.
But the cookie is encrypted and not much you can do with the value anyway. I suspect you want to add data to the cookie, but there are better ways to do it, without having to modify cookie itself.