locked
The value in the session gets changed when page refreshed RRS feed

  • Question

  • User1669121061 posted

    in my asp.net web application I made use of timer which down counts.I have stored value(some 5 min) in session.So I am assigning it to the timer.When I refreshed or switching between different web page, timer resetting again.How about Session value? And how to make it independent of Page refresh.thank you

    Friday, May 11, 2018 8:24 AM

All replies

  • User475983607 posted

    in my asp.net web application I made use of timer which down counts.I have stored value(some 5 min) in session.So I am assigning it to the timer.When I refreshed or switching between different web page, timer resetting again.How about Session value? And how to make it independent of Page refresh.thank you

    It's difficult to provide assistance without the source code.

    I assume this is a JavaScript timer?  If so, you must write code to persist the current timer value.  Then return the value to your JavaScript app when the page is refreshed.  Possible persistent stores include, cookies, database, or Session.

    Friday, May 11, 2018 11:00 AM
  • User61956409 posted

    Hi veeran,

    Firstly, as mgebhard said, you did not share your code, it is difficult to troubleshoot the issue.

    how to make it independent of Page refresh

    Besides, if possible, you can try this approach to implement and initiate your countdown timer:

    1.get the current datetime and add 5 mins to get the end datetime

    DateTime.Now.AddMinutes(5)

    2.save the above end datetime in session

    3.after the page reload, retrieve the end datetime from session, and detect if end datetime > current datetime (DateTime.Now)

    4.if end datetime is not expired, get remaining time (enddatetime - DateTime.Now)

    5.initiate your countdown timer with remaining time

    With Regards,

    Fei Han

    Monday, May 14, 2018 6:42 AM