Facebook-App:设置 FB-cookie/令牌
我有一个 Facebook 应用程序,需要提交一个表格。我只希望用户能够填写一次表格。我想做的是设置一个 cookie + 我想知道是否可以设置类似 FB App-Cookie/令牌之类的东西,它告诉 Javascript 我无法再次提交?
I have a Facebook-App with a form to submit. I only want the users to be able to fill out the form once. What I would like to do is set a cookie + I was wondering if I can set something like a FB App-Cookie/token, that tells Javascript that I can't submit again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的应用程序只是一个常规的 iframe,因此您可以像 Facebook 之外的普通网站一样轻松地设置 cookie。
但不要忘记,您永远不应该信任用户输入,因此您还需要验证服务器上的多个条目 - 通过检查他们的 Facebook 用户 ID 或表单中的某些独特信息(例如用户的例如,电子邮件地址)。
但是,是的,您可以轻松地从 iframe 设置 cookie。不过,您应该进行测试以确保浏览器不会将其作为第三方 cookie 进行阻止。您可以通过将 Firefox 的首选项设置为禁止第三方 cookie 等来轻松测试这一点。
希望这有帮助!
Your app is just a regular iframe, so you can set cookies just as easily as if it were a normal website, outside of Facebook.
Don't forget, though, that you should never trust user input, so you will want to validate against multiple entries on the server as well — either by checking their Facebook user ID or some unique piece of information from your form (like the user's email address, for example).
But yes, you can easily set a cookie from the iframe. You should test to make sure that browsers aren't blocking it as a third-party cookie, though. You can test that easily enough by setting Firefox's preferences to disallow third-party cookies and so on.
Hope this helps!