How to add session and cookie SameSite setting in .NET MVC

Опубликовано: 20 Август 2026
на канале: Authorised Territory
2,016
13

Authorised Territory code examples - This .NET C# #tutorial shows how to add session to MVC website including demo of SameSite cookie setting.
First we create a session with one value and display it.
Next, we change the idle timeou to show that the session expires.
Using SameSite cookie setting as Strict we demonstrate that it does not get attached to the GET request.
Finally, we change SameSite cookie setting from Strict to None and show that cookie does get attached to a GET request.
Finally, to test the SameSite setting we create another simple #dotnet MVC website with just a link to our initial session website.