Logging out randomly
I made a car dealer website for my dad and never had any issues, but months down the road every time he trys to add a car it won't let him cause hes not logged in website just randomly kicks him out not sure what I need to do to fix this?
Thank you
my cookies?
In my local testing nothing happens but only when I publish it it logs me out.
11 Replies
you're gonna have to give us more than that
$details
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
Wasnt sure if it would be my program.cs or my controller
I log in works great but like I said its random when it logs me out but its quick wont last more then 5mins
Maybe you need to set this?
https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.cookies.cookieauthenticationoptions.slidingexpiration?view=aspnetcore-7.0
I'd expect that to be true already, but maybe not?
you need to better understand what's causing you to "log out"
is the cookie being wiped out by something?
is your app rejecting it for some reason?
if you can't replicate this behavior in Development, your best bet is to add an enable as much logging as you can, for the auth system, and examine those after-the-fact in Production
He's literally saying log me out after 30 minutes
since he's not extending the cookie
options.SlidingExpiration = false; // Disable sliding expiration
options.ExpireTimeSpan = TimeSpan.FromMinutes(30); // Set the absolute expiration time
right, be he also claims he's getting logged out after about 5 minutes
I missed that part
I'm not sure what to add to catch these errors I made this website a year ago so my knowledge is very limited
Wasn't sure if I should catch the error in the controller or program.cs
If you remove the false on sliding expiration, what happens?
iirc with sliding expiration set to false, on round trip the cookie isn't extended
I'll test that out when I'm back home working atm
Thank you guys for trying to help