From the course: ASP.NET Core Identity: Authentication Management

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Cookie-based sign-in and out

Cookie-based sign-in and out - ASP.NET Core Tutorial

From the course: ASP.NET Core Identity: Authentication Management

Start my 1-month free trial

Cookie-based sign-in and out

[Instructor] Now that we have learned how to configure cookie-based authentication, how to create a cookie-parser middleware, and how to create an authentication cookie. It is time to use this cookie to sign-in and sign-out from our application. So for that, let us go to our visual studio project. In here, you go to Solution Explorer, and since we have been using the Auth20 project, we need to go to the account controller inside the controllers folder. So I'll just open the account controller and then, scroll down to the login method. So in here, before we create a claim for the user, we need to make sure that this user exists in our database. But on this part, we are not going to implement a logic which checks if the user exists in our database. We will simply use an if condition. So, in line 40, I'll just write if, model.Email is equal to admin@admin.com, and the model.Password is equal to Admin2019!, then we open in here curly brackets. Let us get all the code from line 44 to line…

Contents