Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a website that is accessible (at least from our local campus
network) by four different ways:

1) the full url: /
2) the short url: http://campuslaan37/
3) an alias: /
4) the short alias: http://cam37/

I use cookies to save and set some preferences etc. However, if you
surf from e.g. (1) to (3), it is treated as an entirely different
site, and nothing that was stored in the cookie applies anymore.

Is there a way to set the cookie, such that it immediately applies
to all the possible URLs to access the site?

Thanks in advance,


Re: Cookie

*** Daan wrote/escribi (Tue, 17 Aug 2004 11:54:48 +0200):
Quoted text here. Click to load it

setcookie() has a parameter called domain ("the domain that the cookie is
available"). Then it explains:

"To make the cookie available on  all subdomains of then you'd
set it to ''. The . is not required but makes it compatible
with more browsers. Setting it to will make the cookie
only available in the www subdomain."  

This doesn't exactly apply to your case since your URLs don't have a "tail"
in common. However, I suppose you could use setcookie() to set the cookie
several times, one for each domain. You could write a function to make it

function mysetcookie($name, $value='', $expire='', $path='', $secure=''){
    foreach($aliases as $domain){
        setcookie($name, $value, $expire, $path, $domain, $secure);
Be aware that I didn't test the code. It probably needs to handle empty
parameters differently.

-- lvaro G. Vicario - Burgos, Spain
-- Questions sent to my mailbox will be billed ;-)

Site Timeline