Advertisement
Is there a way to set Cookie domain?
-
- Joomla! Intern
- Posts: 60
- Joined: Sun Jun 17, 2007 7:16 am
Is there a way to set Cookie domain?
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.
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
http://jfusion.org - Universal User Integration
Advertisement
-
- Joomla! Intern
- Posts: 60
- Joined: Sun Jun 17, 2007 7:16 am
Re: Is there a way to set Cookie domain?
Thanks a lot for moving it to the right forum.
Project Manager
http://jfusion.org - Universal User Integration
http://jfusion.org - Universal User Integration
- ianmac
- Joomla! Virtuoso
- Posts: 4784
- Joined: Sat Sep 24, 2005 11:01 pm
- Location: Toronto, Canada
Re: Is there a way to set Cookie domain?
I'm not certain, but I doubt that this will work because this is a browser security issue.radopod wrote:Thanks a lot for moving it to the right forum.
It generally isn't good to be able to set cookies on other site's domains.
Ian
-
- Joomla! Apprentice
- Posts: 13
- Joined: Wed Mar 11, 2009 12:20 pm
- Contact:
Re: Is there a way to set Cookie domain?
No it doesn't work, because of Ian's point. You must install under the same domain.
-
- Joomla! Apprentice
- Posts: 28
- Joined: Tue Mar 25, 2008 3:10 pm
Re: Is there a way to set Cookie domain?
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!!
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!!
-
- Joomla! Apprentice
- Posts: 5
- Joined: Fri Jun 26, 2009 10:36 pm
- Location: Macedonia
Re: Is there a way to set Cookie domain?
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:
Add the following code on a new line right before session_start() is invoked:
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:transforms into
transforms into
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.
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: Select all
session_start();
Code: Select all
ini_set('session.cookie_domain','.mysite.com');
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: Select all
setcookie(session_name(), '', time()-42000, '/');
Code: Select all
setcookie(session_name(), '', time()-42000, '/', '.mysite.com');
Code: Select all
setcookie( JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, '/' );
Code: Select all
setcookie( JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, '/', '.mysite.com' );
Greetings from Macedonia.
Forum signature rules: viewtopic.php?f=8&t=65
-
- Joomla! Apprentice
- Posts: 13
- Joined: Wed Mar 11, 2009 12:20 pm
- Contact:
Re: Is there a way to set Cookie domain?
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.
-
- Joomla! Apprentice
- Posts: 15
- Joined: Mon Oct 27, 2008 3:05 pm
Re: Is there a way to set Cookie domain?
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.
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.
- hefesto
- Joomla! Hero
- Posts: 2579
- Joined: Fri Jan 20, 2006 12:37 am
- Location: Seville - Spain
- Contact:
Re: Is there a way to set Cookie domain?
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
Twitter: @isidrobaq
Comunidad Joomla de España: https://joomlaes.org
NO atiendo peticiones privadas de soporte. Por favor, pregunta en los foros.
Twitter: @isidrobaq
Comunidad Joomla de España: https://joomlaes.org
NO atiendo peticiones privadas de soporte. Por favor, pregunta en los foros.
-
- Joomla! Fledgling
- Posts: 3
- Joined: Fri Oct 01, 2010 4:17 pm
Re: Is there a way to set Cookie domain?
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?
Or would I have to exclusively define www.ping.com as my cookie domain?
Any ideas?
-
- Joomla! Apprentice
- Posts: 5
- Joined: Fri Aug 01, 2008 2:37 am
Re: Is there a way to set Cookie domain?
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.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:Add the following code on a new line right before session_start() is invoked:Code: Select all
session_start();
Fix Cookies:Code: Select all
ini_set('session.cookie_domain','.mysite.com');
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:transforms intoCode: Select all
setcookie(session_name(), '', time()-42000, '/');
Code: Select all
setcookie(session_name(), '', time()-42000, '/', '.mysite.com');
transforms intoCode: Select all
setcookie( JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, '/' );
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.Code: Select all
setcookie( JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, '/', '.mysite.com' );
Greetings from Macedonia.
After trying both I did clear all cache and cookies and even reopened the browser with the same issue.
Advertisement