1

我想知道是否有办法告诉 TYPO3 在不同域之间共享会话/cookie?

我们在多语言/多域站点上编写了 Extbase 扩展。我们将搜索表单中的搜索词存储在用户会话中。如果用户切换页面语言,他应该得到与以前相同的结果——无需重新填写搜索表单。

一种方法是告诉浏览器同时存储多个 cookie - 每个域/语言一个。TYPO3 / Extbase 如何做到这一点?

4

1 回答 1

2

By default, there is no way to set cookies for a different domain - not with or without TYPO3. This is a security measure implemented in every browser (or do you want me to set / read your cookies from yourbank.com when you visit my web site? ;-))

You have to create some helper script that does this for you. One way could be:

  • example.com is loaded
  • this page includes an iframe to a PHP script (or TYPO3 site, e.g. with eID) on example.org with a GET parameter storing being the session id
  • the script loaded from example.org reads the GET parameter and sets a cookie with that session id (or whatever parameter you want to transfer).
  • afterwards the cookie is also available when browsing example.org

I have never tried this, but I'm pretty sure it will work with PHP. Maybe it's even possible with pure JavaScript, but I'm not so sure. In every case, think about what security holes you get with the explained script. In doubt sign the parameters (or require a token)!

于 2013-05-03T05:33:29.617 回答