Forum Moderators: phranque

Message Too Old, No Replies

Cross Domain Cookie Woes

         

volatilegx

6:09 pm on Jan 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have an e-com site that sets a cookie when any page on the site is visited. That cookie records the referring URL and the URL used to visit my site, including any query information in the URL...

The problem is that when somebody makes a purchase, they go over to my secure server, which is on a different domain name, and the order form page is unable to read the cookie set by the page they originally came in on.

What I want to know is, when you set a cookie, is it possible to specify that the cookie will be read by a different domain? And how would you code this in JavaScript?

jatar_k

6:57 pm on Jan 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What about reading the cookie before they get sent to the other site and then passing the info over there?

Are the two sites on the same box? You could then maybe dump it somewhere and pick it up on the other site.

I don't believe you can read cookies on another domain.

volatilegx

7:10 pm on Jan 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Currently I have some JavaScript that rewrites the URL of the order form with query info that duplicates the cookie. The order form sets a cookie of its own with the same info. The visitor ends up with two different cookies.

This just seems like a messy way to do it.

jatar_k

7:14 pm on Jan 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



true, but I think it is the best option available.

volatilegx

7:18 pm on Jan 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was thinking, could this be done using an invisible iframe on the pages on the primary domain? The iframe would pull a page from the same domain as the order form which would contain javascript to set a cookie...

jatar_k

7:20 pm on Jan 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



that actually sounds like it might work. I don't use iframes much but the premise seems sound.

volatilegx

7:55 pm on Jan 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'll give something like that a try and post here with results :)