如何在Google网站上创建Cookie? [英] How to create a cookie on a Google site?

查看:159
本文介绍了如何在Google网站上创建Cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个包含5个链接的Google网站页面。是否可以在我的网站上创建一个脚本或存储在Cookie中的链接用户点击的链接,然后下一次他将连接到该页面,他将被自动重定向到他点击的链接?有关信息,用户使用其Google电子邮件帐户连接到该网站。

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.

我该如何做?

提前非常感谢您的帮助

推荐答案

虽然可以使用JavaScript在Google中读取Cookie和重定向页面(使用窗口小部件),浏览器不允许您为出于明显的安全原因,这是一个完全不同的域。

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.

相关:

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

您理论上可以尝试从Google页面发送一个AJAX请求,其中包含我应该将此用户定向到哪里?并期望一个网址或空值。

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.

查看:

  • 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.

这篇关于如何在Google网站上创建Cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆