How to create a cookie on a Google site?

二次信任 提交于 2020-01-17 10:07:08

问题


I created a Google site page with 5 links on it. Is it possible to create on my site a script or something that stores in a cookie the link on which the user has clicked, and then the next time he will connect to the page, he will be automatically redirected to the link he clicked on ? For information, the user connect to the site with his Google email account.

How can I do that please?

Thank you very much in advance for your help


回答1:


While it is possible to read cookies and redirect using JavaScript inside a Google Page (using widgets), browsers will not allow you to set cookies for a completely different domain for obvious security reasons.

Related:

  • How to set a cookie for another domain
  • Cross-Domain Cookies
  • What's your favorite cross domain cookie sharing approach?

You could theoretically try and send an AJAX request from the Google Page with a "where should I direct this user to?" and expect a URL or a null.

See:

  • CORS $.ajax session cookies (access-control-allow-credentials & withCredentials=true)
  • Cross domain POST request is not sending cookie Ajax Jquery

But overall, your task is not as straightforward as it may seem. The browser will, fortunately, not play along.



来源:https://stackoverflow.com/questions/20355629/how-to-create-a-cookie-on-a-google-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!