Search code examples
c#asp.net-mvcsimplemembership

mvc4 Automatically log in user during email-confirmation


I send out an Email with a confirmation tocken (from the webpages_Membership table) when the user registers on my site.

When the user clicks the link I confirm the Account:

 WebSecurity.ConfirmAccount(guid);

I would now like to log the user in as sugested in this post: Is it a bad idea to automatically log users in from an email?

How do I do that?


Solution

  • If you are using the standard membership system, you should call

    FormsAuthentication.SetAuthCookie("username", true);
    

    http://msdn.microsoft.com/en-us/library/twk5762b.aspx