The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Fri Mar 06, 2009 7:39 pm 
Joomla! Intern
Joomla! Intern

Joined: Sun Jun 17, 2007 7:16 am
Posts: 60
Hey all
I have been looking for a way to achieve this for a few weeks now but have found nothing. Finally I decided to bother you guys. ;) So is it possible to set the Cookie domain in Joomla!?

I need this so that we can get the JFusion Component of ours to bridge multiple Joomla! installations in such a way that dual login works across sub domains on a single domain.

Looking forward to a reply soon.

Thanks in advance.

_________________
Project Manager
http://jfusion.org - Universal User Integration


Top
 Profile  
 
PostPosted: Fri Mar 06, 2009 7:42 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Aug 18, 2005 10:41 am
Posts: 15750
Moderator note; moving to correct forum

_________________
Regards Robin

http://www.linkedin.com/in/robinmuilwijk - http://twitter.com/i_robin


Top
 Profile  
 
PostPosted: Fri Mar 06, 2009 7:51 pm 
Joomla! Intern
Joomla! Intern

Joined: Sun Jun 17, 2007 7:16 am
Posts: 60
Thanks a lot for moving it to the right forum.

_________________
Project Manager
http://jfusion.org - Universal User Integration


Top
 Profile  
 
PostPosted: Sat Mar 07, 2009 1:25 am 
User avatar
Joomla! Virtuoso
Joomla! Virtuoso

Joined: Sat Sep 24, 2005 11:01 pm
Posts: 4779
Location: Toronto, Canada
radopod wrote:
Thanks a lot for moving it to the right forum.


I'm not certain, but I doubt that this will work because this is a browser security issue.

It generally isn't good to be able to set cookies on other site's domains.

Ian


Top
 Profile  
 
PostPosted: Tue Mar 24, 2009 8:38 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Mar 11, 2009 12:20 pm
Posts: 13
No it doesn't work, because of Ian's point. You must install under the same domain.


Top
 Profile  
 
PostPosted: Thu Jun 25, 2009 11:22 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Mar 25, 2008 3:10 pm
Posts: 28
it's not about setting a cookie to a different domain... but having control as to whether or not you use www.mydomain.com or .mydomain.com

We're bridging PHPBB and Joomla/Virtuemart, and having great difficulty, because of not being able to clearly show the format cookies need to be in. Virtuemart seems to set some with www and others without... which is doubly confusing.

This is discussed:
http://joomlacode.org/gf/project/joomla ... m_id=16939
http://groups.google.com/group/joomla-d ... raot&pli=1
http://www.joomlashack.com/joomla-how-t ... n-mismatch

In case anyone else wants to see the best progress of this I've seen so far.. there is a hack that exists to be able to set the cookie domain for Joomla, and hopefully will make the next version!!


Top
 Profile  
 
PostPosted: Fri Jun 26, 2009 10:48 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Jun 26, 2009 10:36 pm
Posts: 5
Location: Macedonia
Hi! I posted this solution in the JFusion forums; I am posting it here as well. I hope it helps. ;)

To fix the login issue, two problems need to be solved: setting cookies and opening sessions. We need to tell Joomla to always use our top domain (and not subdomains) for these operations.

Be sure to replace mysite.com with your actual domain name below.

Fix Sessions:

File to edit:
\libraries\joomla\session\session.php

Find the two occurences of the line:
Code:
session_start();

Add the following code on a new line right before session_start() is invoked:
Code:
ini_set('session.cookie_domain','.mysite.com');

Fix Cookies:

Files to edit:
/libraries/joomla/application/application.php
/libraries/joomla/session/session.php
/plugins/system/remember.php

Find all the occurences of the setcookie(...) function in the files above.

Add an additional (domain) parameter: '.mysite.com'

Examples:
Code:
setcookie(session_name(), '', time()-42000, '/');
transforms into
Code:
setcookie(session_name(), '', time()-42000, '/', '.mysite.com');


Code:
setcookie( JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, '/' );
transforms into
Code:
setcookie( JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, '/', '.mysite.com' );

I am aware that this is not the most elegant solution, but it gets the job done. I hope this will help many site owners use the wonderful JFusion extension. Thanks to the JFusion team for bringing us this wonderful piece of software.

Greetings from Macedonia.

_________________
Хороскоп.


Top
 Profile  
 
PostPosted: Wed Jul 01, 2009 4:37 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Mar 11, 2009 12:20 pm
Posts: 13
Mihajlovski! Thanks a ton! I'm trying this solution right now. I hadn't yet gotten JFusion to work properly and gave up completely on my Joomla site. This shows what effects on Joomla's useability and our preference to stick with it that an incompletely programmed extension can cause. I hope this works. Keep your fingers crossed, say a prayer.


Top
 Profile  
 
PostPosted: Thu Apr 01, 2010 3:57 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Oct 27, 2008 3:05 pm
Posts: 15
thanks mihajlovski you're a legend :)

Still, its kind of annoying that you need to edit all these core files to do something so simple. Surely it must be a common thing to want to share cookies between mysite.com and www.mysite.com? Would be good to have some config option in Joomla for this.


Top
 Profile  
 
PostPosted: Tue Apr 27, 2010 4:00 pm 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Fri Jan 20, 2006 12:37 am
Posts: 1851
Location: Seville - Spain
Instead of hacking the core, wouldn't it be easier redirecting non www domain to www domain (or vice versa) using htaccess?

_________________
Spanish forum local moderator -- Community Leadership Team (CLT) Member

http://www.gnumla.com || Twitter: @isidrobaq - @gnumla || Facebook: http://www.facebook.com/gnumla
NO atiendo peticiones privadas de soporte. Por favor, pregunta en los foros.


Top
 Profile  
 
PostPosted: Tue Nov 23, 2010 5:27 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri Oct 01, 2010 4:17 pm
Posts: 3
How would you go about setting up a cookieless subdomain. Ex. I have ping.com and i want to serve my images from assets.ping.com and make that a cookieless domain.

Or would I have to exclusively define www.ping.com as my cookie domain?

Any ideas?


Top
 Profile  
 
PostPosted: Tue Dec 28, 2010 6:07 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Aug 01, 2008 2:37 am
Posts: 5
mihajlovski wrote:
Hi! I posted this solution in the JFusion forums; I am posting it here as well. I hope it helps. ;)

To fix the login issue, two problems need to be solved: setting cookies and opening sessions. We need to tell Joomla to always use our top domain (and not subdomains) for these operations.

Be sure to replace mysite.com with your actual domain name below.

Fix Sessions:

File to edit:
\libraries\joomla\session\session.php

Find the two occurences of the line:
Code:
session_start();

Add the following code on a new line right before session_start() is invoked:
Code:
ini_set('session.cookie_domain','.mysite.com');

Fix Cookies:

Files to edit:
/libraries/joomla/application/application.php
/libraries/joomla/session/session.php
/plugins/system/remember.php

Find all the occurences of the setcookie(...) function in the files above.

Add an additional (domain) parameter: '.mysite.com'

Examples:
Code:
setcookie(session_name(), '', time()-42000, '/');
transforms into
Code:
setcookie(session_name(), '', time()-42000, '/', '.mysite.com');


Code:
setcookie( JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, '/' );
transforms into
Code:
setcookie( JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, '/', '.mysite.com' );

I am aware that this is not the most elegant solution, but it gets the job done. I hope this will help many site owners use the wonderful JFusion extension. Thanks to the JFusion team for bringing us this wonderful piece of software.

Greetings from Macedonia.


This does not work in J! 1.5.22, what version was this tried on. It caused my login to authenticate but not actually show logged in on the user side (backend showed login or multiple if retried). Do not attempt to use http://joomlacode.org/gf/project/joomla ... m_id=19948 either since that does the samething but implements a config variable in the configuration.php to turn it on or off (did the same as above code). I know in J! 1.6 they are playing with the same thing, but since not a full release not going to upgrade to it yet.

After trying both I did clear all cache and cookies and even reopened the browser with the same issue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 



Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group