Home > Software engineering >  .netcore session variables always null
.netcore session variables always null

Time:10-13

I have a .netcore 5.0 web api. And I want to implement session variables for users when logged in. I believe I followed all the steps on multiple tutorials.

Here is what I've done so far Startup.c:

enter image description here

Configure method

My controller class

controller constructor

I have a vuejs app, when I refresh the page I call "OnLoadPage", and when I click a button I call "OnPageGet". Session variable seems to be set in the scope of the http call, but when I make another http request the session ID fully changes and all my variables are null.

What am I missing please help. Thank you.

endpoints

CodePudding user response:

I realized it's necessary to setup some cookie parameters to make it work. In my developper tools I noticed an error on the response of my "PageLoad" request, where it said "samesite error" I just had to add this configuration parameter to my startup and it fixed it.

session cookie parameters

  • Related