Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-19-2007, 03:42 AM   PM User | #1
x452
New to the CF scene

 
Join Date: Jun 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
x452 is an unknown quantity at this point
Setting cookies across multiple domains

Hi,

Say I have the following domains which all direct to the one website:

www.first.com
www.first.com.au
www.firstbank.com
www.firstbank.com.au
www.fb.com
www.fb.com.au

I want to set the same cookie across all of the above domains, which will be set if the customer uses any of the following addresses:

www.first.com
first.com
www.first.com.au
first.com.au
www.firstbank.com
firstbank.com
www.firstbank.com.au
firstbank.com.au
www.fb.com.au
fb.com.au
www.fb.com
fb.com

How do I do this?

Thanks,
Andrew
x452 is offline   Reply With Quote
Old 06-19-2007, 04:10 AM   PM User | #2
smalldog
Regular Coder

 
Join Date: May 2007
Posts: 118
Thanks: 0
Thanked 0 Times in 0 Posts
smalldog is an unknown quantity at this point
IMHO you can't set the cookie for multiple domains, cookies are automatically set for the actual domain and that's the logic of the browsers.

You can just make some workaround for this, for example redirect other domains to one domain. For example www.first.com.au redirect to www.first.com/au etc
__________________
Forum for webmasters and developers
http://www.htmlfrenzy.com
Are you an IT expert? Join our Reward system
www.htmlfrenzy.com/reward-system.php
smalldog is offline   Reply With Quote
Old 06-19-2007, 05:02 AM   PM User | #3
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
You can set the domain for the different sites with the same subdomain. For example, for the following sites, if you set the domain to .yahoo.com, the cookie is accessible to all of them.
Code:
www.yahoo.com
mail.yahoo.com
photos.yahoo.com
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 06-20-2007, 12:38 AM   PM User | #4
x452
New to the CF scene

 
Join Date: Jun 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
x452 is an unknown quantity at this point
Quote:
Originally Posted by smalldog View Post
You can just make some workaround for this, for example redirect other domains to one domain. For example www.first.com.au redirect to www.first.com/au etc
That sounds like a good idea, I wonder if I can redirect all my domains to www.first.com.au? So if a user goes to www.first.com they will be redirected to www.first.com.au and I wonder if this redirection will be seamless?

All my domains point to the one web server, would I do the domain redirect at the domain supplier level?

Quote:
Originally Posted by glenngv View Post
You can set the domain for the different sites with the same subdomain. For example, for the following sites, if you set the domain to .yahoo.com, the cookie is accessible to all of them.
Code:
www.yahoo.com
mail.yahoo.com
photos.yahoo.com
Yeah I knew about this one but unfortunately it wouldn't work as all my sites are domains rather than sub-domains. So setting the domain to .first.com would not work for first.com or www.first.com.au.

Last edited by x452; 06-20-2007 at 01:01 AM..
x452 is offline   Reply With Quote
Old 06-21-2007, 08:06 AM   PM User | #5
x452
New to the CF scene

 
Join Date: Jun 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
x452 is an unknown quantity at this point
Can the solution in this article be done using javascript? http://www.15seconds.com/issue/971108.htm

If yes if anyone can give me the code that would be great.
x452 is offline   Reply With Quote
Old 06-21-2007, 08:09 AM   PM User | #6
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,292
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
The answer is no. That article is meant to be used with ASP pages. As said before Javascript can't go across domains due to security reasons. Are all of your URLs hosted on the same server? If they are then you may be able to use a server side script.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 06-22-2007, 12:03 AM   PM User | #7
x452
New to the CF scene

 
Join Date: Jun 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
x452 is an unknown quantity at this point
Quote:
Originally Posted by _Aerospace_Eng_ View Post
Are all of your URLs hosted on the same server? If they are then you may be able to use a server side script.
Yes they are. How I could do this with server side script?
x452 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:45 AM.


Advertisement
Log in to turn off these ads.