简体   繁体   English

使用setinterval保存到localstorage

[英]save to localstorage using setinterval

I'm developing a quiz with stopwatch, to calculate how much time user spent answering the quiz. 我正在开发一个带秒表的测验,以计算用户花在回答测验上的时间。 But it's hackable by the user if the user refresh the browser. 但是如果用户刷新浏览器,用户就会破解它。

Hmm what should I do? 嗯我该怎么办? should I save the the counter to localstorage every seconds? 我应该每隔一秒将计数器保存到本地存储吗? and resume? 和简历?

No, local storage is entirely under the control of the user as well. 不,本地存储也完全在用户的控制之下。

You'll need to track the information server-side: Have the server record when user X started task Y, and have the server record when they completed it. 您需要跟踪服务器端的信息:在用户X启动任务Y时记录服务器,并在完成任务时记录服务器记录。 Nothing you can do client-side will be resistant to an even modest attempt at bypassing. 客户端无法做到的任何事情都无法抵抗绕过的平庸尝试。

Even the server approach can be susceptible to bypassing by bad actors (for instance, I sign up for multiple accounts, get all my answers together, and then sign up "for real" and take the quiz in record time). 即使是服务器方法也很容易被坏人绕过(例如,我注册多个帐户,一起得到我所有的答案,然后注册“真实”并在记录时间内参加测验)。 You'll always be in an arms race (IP checking, etc.), but at least you'll have some small chance by using something somewhat outside the user's control. 你将永远处于军备竞赛(知识产权检查等),但至少你可以通过使用某些超出用户控制范围的东西获得一些小机会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM