c# - Renewing forms authentication ticket - strange timing -


i'm using forms authentication successfully, have run strange issue. i've looked around web, , haven't found answer far.

i'm using javascript determine when current session 60 seconds away timing out, , if - pop dialog box button which, if pressed, extend current formsauthentication ticket.

this code i'm using renew ticket. i'm add 5 minutes current expiration date of ticket. when output new expiration date, it's under 5 minutes; 4 minutes , seconds.

the code:

    string userid = httpcontext.current.user.identity.name;     httpcookie cookie = formsauthentication.getauthcookie(userid, true);      formsauthenticationticket ticket = formsauthentication.decrypt(cookie.value);      datetime new_expiry = datetime.now.addminutes(formsauthentication.timeout.minutes);      formsauthenticationticket newticket = new formsauthenticationticket(         ticket.version,          userid,          datetime.now,         new_expiry,         ticket.ispersistent,         ticket.userdata,         ticket.cookiepath);      cookie.value = formsauthentication.encrypt(newticket);      if (ticket.ispersistent) cookie.expires = newticket.expiration;      cookie.secure = formsauthentication.requiressl;      httpcontext.current.response.cookies.add(cookie); 

so, here's example output of time differences:

the time stamp = 16/01/2016 14:03:28 ticket expires=16/01/2016 14:07:49 (total seconds=261.0857244)

why not resetting expiration time 14:08:28?? i'm banging head on wall here...

ok still don't know why expiration value formsidentity object incorrect... i've done passed actual new expiration value (as datetime) renewal method,and relied on that. seems value correct, , that's value should using determine real time out value.

does make sense? dunno, it's working now!


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -