在域/子域上设置Cookie [英] Setting cookies on domain/subdomain
问题描述
您好,有很好的人StackOverflow,我有一个问题,我希望你们中有些人可能能够帮助我。
假设我应该在www.webshop.com域创建一些Wordpress网上商店,用英语写成,一个名为cartItems的cookie可用于该域。好吧,不是问题。
Hi there good people of StackOverflow, I have a problem and I was hoping that some of you out there might be able to help me. Let's say I am supposed to create some kind of Wordpress web shop on www.webshop.com domain, written in English language, with a cookie named 'cartItems' available for that domain. Ok, not a problem.
问题是,我还需要制作一个德国版的网站,我需要在英语和德国的cookie之间做出区别。
The problem is that I also need to make a german version of the site and I need to make difference between english and german cookies.
现在,我的问题是,如果例如德国网站在www.webshop.com/de/,我可以设置一个德国cookie只能用于/ de /域,对吗?
但是如何设置英语cookie将在除了/ de / one之外的所有域中可用。
Now, my question is, if for example the german site is on the www.webshop.com/de/ I can set a german cookie to be available only for the /de/ domain, right? But how can I set that english cookie will be available in all the domains except the /de/ one.
如果不能这样做
感谢所有的帮助
推荐答案
有三种方式可以分隔英语和德语cookie
There are 3 ways you can separate the English and German cookies
1)域名:
您可以使用单独的www 。和de。子域名。对我来说这将是最简单的
1) Domain: You could use a separate www. and de. subdomain as you mentioned. To me this would be the easiest
2)路径:
你可以使用路径,但如果你的英语cookie设置为/可在/ de /下访问。因此,如果你想走这条路线,你需要创建一个/ en /路径Kerrek建议。
2) Path: You can use the path, but if your English cookie is set for "/" it will still be accessible under "/de/". So if you want to go this route you'd need to make a "/en/" path as Kerrek suggested.
3)名称:
德语Cookie使用不同的名称
3) Name: Give the German cookie a different name
您需要执行其中一个步骤,才能拥有单独的英语和德语Cookie。我认为有一个单独的子域是最好的,因为不只是你的cookie路径,但所有的资产路径将是相同的,无论语言。
You will need to do one of those 3 to have separate English and German cookies. I'd think that having a separate subdomain would be the best, because not just your cookie paths but all your asset paths will be the same regardless of language.
这篇关于在域/子域上设置Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!