英文:
Retain variable value in javascript in different browser
问题
在JavaScript中,是否可能在不同的浏览器中保留变量的值?我尝试过localStorage和sessionStorage,但它只在当前浏览器中有效。
我可以提供一个示例代码来实现这个吗?
谢谢。
英文:
Is it possible in javascript to retain the value of a variable not just in one browser but in a different browser? I tried localStorage and sessionStorage but it only works on the current browser only.
Can I have a sample code on how to achieve that?
Thank you.
答案1
得分: 1
一般来说,不可以。如果可能的话,这将构成巨大的安全风险。在您的情况下,数据应该保存在后端服务器或某种在线存储上。这是唯一的方法。
另外,请不要在stackoverflow上要求示例代码。SO更像是一个“知识数据库”,用于提出具体问题并寻找最佳解决方案,而不仅仅是提供“示例代码”。
英文:
Generally speaking, no - it cannot be done. If it were possible, it be a huge security risk. In your case, data should be saved on a backend server or some kind of online storage. That is the only way to do so.
Also, dont ask for sample code on stackoverflow. SO is more of a "knowledge database" - asking for specific problems and finding optimal solutions, rather than just providing "sample code".
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论