...

View Full Version : cookies stored on localhost



habib
10-20-2003, 01:58 PM
Hello PPl,

I would like to know if cookies are stored when testing website on localhost?

The problem I am having is when I view the site locally my cookie script is finding two different values for the same cookie. I think its taking one value from the 'local cookie' and the other from when I view the site on a 'LIVE' host (internet).

I have tried to delete all the cookies but the problem is still there. I am using Win2K and use php pages with an Apache Server. The code to set cookies, delete cookies and get cookies are JavaScript and not PHP.

Many thanks

-Habib

habib
10-24-2003, 01:47 PM
any ideas?

liorean
10-24-2003, 03:28 PM
Cookies are depending on the domain - so if you are loading the document from a different domain, it will nto have access to the cookies it set on the other domain. And localhost is not only another domain but an entirely different protocol (I guess you mean localhost as in using the file protocol), unless you have a local server running from which you load the file.

habib
10-29-2003, 10:14 AM
thankyou for replying...


Cookies are depending on the domain so if you are loading the document from a different domain, it will nto have access to the cookies it set on the other domain

From this, my understanding is that if a user logged onto www.mydomain.com - a cookie is created with this domain, and if a user accesses www.mydomain.co.uk - a different cookie would be created and the values from the .com cookie would not be used. Is there any code I can use to set or retrieve data from cookies from a specific domain and ignore all else?

Regards
Habib

glenngv
10-29-2003, 12:49 PM
you can only retrieve the cookie that matches the current document's domain with the cookie's domain attribute.

http://wp.netscape.com/newsref/std/cookie_spec.html

liorean
10-29-2003, 04:43 PM
You can SET a cookie for another domain, however. Whether the browser accepts it depends on the settings and the user.

habib
10-31-2003, 11:58 AM
So if I wanted to set a cookie for any domain name that contained 'mydomain' and only use the values from this cookie - would this be possible?

For example...

I have purchased lots of domain names - (they all have the same) -

mydomain.com
mydomain.net
mydomain.org
mydomain.co.uk and so on....

If a user enters my site using '.com' a cookie is set, the user leaves the site and at a later date returns to my site but this time the user uses '.co.uk' - I want to use the values from the '.com' cookie for this user.

Is this possible?

-Habib

liorean
10-31-2003, 12:03 PM
No. You have to set the cookie explicitly for each domain you want.

habib
11-01-2003, 01:31 PM
ok,

Thankyou very much for your help and support.

-Habib

glenngv
11-04-2003, 02:16 PM
if you have subdomains like below:

a.b.c.mydomain.com
x.y.z.mydomain.com
g.mydomain.com
h.i.mydomain.com

you can set the cookie domain as ".mydomain.com" so that the cookie is visible to all subdomains with that domain.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum