Base solution for your next web application
Open Closed

When will the Cookie become expired or invalidated? #567


User avatar
0
xumx created

On my mobile app, I've stored the Cookie and it works fine.

However, some users start to get ("unAuthorizedRequest": true) "No user logged in!" Error. seems like AbpSession.UserId has no value anymore.

I'm trying to figure out what is the root cause. Will cookies or auth token invalidate on server reboot? or after a number of days? Where can I configure the expiry period.


3 Answer(s)
  • User Avatar
    0
    xumx created

    Ok I think I've found the config code for API token.

    AccountController : AbpApiController

    var currentUtc = new SystemClock().UtcNow;
                ticket.Properties.IssuedUtc = currentUtc;
                ticket.Properties.ExpiresUtc = currentUtc.Add(TimeSpan.FromMinutes(30));
    

    Still looking for the cookie expiry

  • User Avatar
    0
    xumx created

    I guess I just have to set 'IsPersistent' to true

    AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = rememberMe }, identity);
    
  • User Avatar
    0
    hikalkan created
    Support Team

    Yes, you found it. AuthenticationProperties has also ExpiresUtc property if you need.