I have a website where on completion of a task, you are allowed access for a set period, I have this access set by creating / storing a cookie after completion of the task, when this cookie is found on the site it will stop the redirect.
(我有一个网站,在该网站上完成一项任务后,您可以在一段指定的时间内访问该网站,我通过在任务完成后创建/存储Cookie来设置此访问权限,当在网站上找到该Cookie时,它将停止重定向。)
Super simple by works.(超级简单的作品。)
I am using a javascript cookie library.(我正在使用JavaScript Cookie库。)
Some issues I have now experienced is some users, must have browsers that clear cookies after closing, causing access cookies to be removed and then making them complete tasks again for access.
(我现在遇到的一些问题是某些用户,必须具有关闭后清除cookie的浏览器,导致删除访问cookie,然后使它们再次完成访问任务。)
Some users also figured out a little hack in local storage and now are bypassing the tasks.(一些用户还发现本地存储中存在一些漏洞,现在正在绕过任务。)
What are some ways, I can store or allow access after completion of tasks without the risk of them clearing out in a cookie?
(在完成任务后,我可以通过哪些方式存储或允许访问,而又不会在cookie中清除它们的风险?)
Starting to think cookies in local storage is not the best approach as they are able to be edited.(开始考虑在本地存储中使用cookie并不是最好的方法,因为可以对其进行编辑。)
My code
(我的密码)
if(taskData === true){
Cookies.set('completed','true', { expires: 10});
location.href = 'www.website.com';
}
});
If this cookie is found by my original site, and true it allows access.
(如果此cookie是在我的原始网站上找到的,则为true,则允许访问。)
ask by PHPNoob translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…