save questionnaire time

1

I made a questionnaire with php and javascript, that's all right. Just a little detail I'm not sure what the best way to do it.

The questionnaire has a time to be answered, and I would like it if the responding user leaves the page or updates, the time starts to count from where he left off. I thought of doing an ajax request recording in the bd every 2s the time, but I would like to avoid something that made so many requests to the database in such a short time so, even more that the system is in amazon, I want to avoid not to generate costs additional.

I thought in other ways, such as sessions and cookies but either one is not efficient for this.

If you can help me I'm very grateful, I just need a hint of what would be in your experience a more viable option.

    
asked by anonymous 19.01.2018 / 12:50

1 answer

2

You can use localStorage , it provides access to local storage for a specific domain, allowing you, for example, to add, modify, or delete stored data items.

Saving% w / o time and an id to the user:

storage.setItem(usuario, tempo);

Reading the value:

var tempo = storage.getItem(usuario);

You can use this because data stored in localStorage does not expire.

More information: link

    
19.01.2018 / 14:11