Re: multiple domains using one cookie
| From: | Mark Maggelet | Date: | Thu, 05 Jul 2001 18:45:45 +0000 |
| Subject: | Re: multiple domains using one cookie | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-56357@lists.php.net to get a copy of this message | ||
On Thu, 5 Jul 2001 14:59:19 +0200, Tobias Talltorp
(tobias@talltorp.com) wrote:
>Hello all.
>
>I want multiple domains to be able to read from one cookie, or set
>one
>cookie each for the different domains.
>
>Here is the case:
>When the user logs in to my server, I want to set a cookie that has
>the
>value $name="tobias". He specifies which domains that can read this
>cookie,
>something like $domains="domain1.com;domain2.com;domain6.com".
>Then these sites can read the $name and print it.
>
>The other way might be to set one cookie with the value
>$name="tobias" for
>domain1.com, one for domain2.com and one for domain6.com.
>But the cookie _has_ to come from domain1.com, otherwise it will
>only work
>for mydomain.com, right?
>In other words, I can´t set, edit or read a cookie for an other
site?
>
>How would I go about doing this?
right, you can't do it. the browser won't accept a cookie for a
domain other than the one it's coming from, and it won't send a
cookie for a domain other than the one that's being requested.
a couple of ideas for a workaround would be:
1) you can set a cookie on domain1, redirect to a page on domain2
which sets another cookie, redirects to domain6 and sets another
cookie and redirects back to domain1 (messy)
2) you can restructure your domains into subdomains like so:
www1.domain.com
www2.domain.com
www3.domain.com
these will all get and send cookies for domain 'domain.com'