FEATURE REQ: Cookie settings in Global Configuration

Locked
TeodorX
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Aug 17, 2008 9:11 am
Location: Romania
Contact:

FEATURE REQ: Cookie settings in Global Configuration

Post by TeodorX » Sun Aug 17, 2008 9:51 am

Domain cookie settings in Global Configuration under Site or System.
Could solve multiple issues with compatibility with 3rd party applications (bridges, forums, galleries and so on) that require logon on different subdomains.

Example:
- running main joomla site on joomla.somedomain.xyz
- a forum on forum.somedomain.xyz
- a gallery on gallery.somedomain.xyz

a) User is logging on Joomla:
- Joomla is setting cookie for joomla.somedomain.xyz
- (through bridges) cookies for forum and gallery are set for .somedomain.xyz
- logging succes for site / forum / gallery

b) User is logging on forum:
- cookies for forum are set for .somedomain.xyz
- in current configuration (through bridge) Joomla is setting cookie for forum.somedomain.xyz
- logging succes in forum - loggin failed in Joomla.

Solution:
Domain seetings for cookies in Joomla global configuration.
Setting manually Joomla cookies domain to .somedomain.xyz solve this. In case this parameter is not set, Joomla should behave like until now: set cookies for default domain.

TeodorX
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Aug 17, 2008 9:11 am
Location: Romania
Contact:

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by TeodorX » Sun Aug 17, 2008 8:57 pm

Problem solved.
If anyone from Joomla Team is interested just drop me a PM with info where to send the code.

saki
Joomla! Intern
Joomla! Intern
Posts: 57
Joined: Thu Jul 10, 2008 9:10 pm

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by saki » Fri Oct 03, 2008 5:53 pm

Where are the cookie settings configured in Joomla?

TeodorX
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Aug 17, 2008 9:11 am
Location: Romania
Contact:

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by TeodorX » Mon Oct 06, 2008 12:41 pm

In default Joomla install is doesn't exists such feature.
I had to patch the code myself to implement it.

saki
Joomla! Intern
Joomla! Intern
Posts: 57
Joined: Thu Jul 10, 2008 9:10 pm

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by saki » Mon Oct 06, 2008 4:46 pm

So there is not a way to configure the cookies - can you explain how you did it or is it too complicated?

thehulaqueen
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Mar 25, 2008 3:10 pm

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by thehulaqueen » Thu Jun 25, 2009 11:08 pm

I would love to know too!! We're running into problems with JFusion and some cookies having www and others now.

mihajlovski
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Jun 26, 2009 10:36 pm
Location: Macedonia

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by mihajlovski » Fri Jun 26, 2009 10:47 pm

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: Select all

session_start();
Add the following code on a new line right before session_start() is invoked:

Code: Select all

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: Select all

setcookie(session_name(), '', time()-42000, '/');
transforms into

Code: Select all

setcookie(session_name(), '', time()-42000, '/', '.mysite.com');

Code: Select all

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

Code: Select all

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.
Forum signature rules: viewtopic.php?f=8&t=65

thehulaqueen
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Mar 25, 2008 3:10 pm

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by thehulaqueen » Fri Jun 26, 2009 10:59 pm

Thank you so much!!

We did a change to .htaccess to rewrite all url's without the www in front of them

Here it is:
# Redirect all www requests to non www, to solve canonical issues
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule (.*) http://%1/$1 [R=301,L]

Before we did this bout half our cookies were being set with www and half without. This was causing Joomla to log out every once in a while, and for some users never log in. VirtueMart seems to set both www and non-www cookies. The only problem left was after you clear all cookies, you get a session expired message the first time you try to log in, and I think you just supplied the fix for that. Thank you!!!

With that .htaccess change all cookies are set without the www. I'm not technical enough to know why, but it works.

In JFusion we used cookie domains of .mysite.com.

Thanks again for sharing!

thehulaqueen
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Mar 25, 2008 3:10 pm

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by thehulaqueen » Fri Jun 26, 2009 11:06 pm

This might be silly question.. but what parts of the following do I substitute my own information??

ini_set('session.cookie_domain','.mysite.com');

Do I replace cookie_domain and .mysite.com??

mihajlovski
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Jun 26, 2009 10:36 pm
Location: Macedonia

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by mihajlovski » Fri Jun 26, 2009 11:16 pm

In the line:

Code: Select all

ini_set('session.cookie_domain','.mysite.com');
Replace only mysite.com with your actual site. Don't forget that second dot.

Example:

Code: Select all

ini_set('session.cookie_domain','.thehulaqueen.com');
Forum signature rules: viewtopic.php?f=8&t=65

thehulaqueen
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Mar 25, 2008 3:10 pm

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by thehulaqueen » Fri Jun 26, 2009 11:22 pm

I've just done some more testing... our .htaccess fix solved our login issues... I was thinking I needed to do the session fix above, but realized my session issue was pretty small.

For me to get the session expired message I have to:
- Log out of the site
- Clear all cookies
- Attempt to login again

If I close the browser, then navigate to the site again, first time login works.

Using cookies of .mydomain.com we are successfully bridging Joomla, PHPBB and Virtuemart.

Yahhh!

powerPT
Joomla! Intern
Joomla! Intern
Posts: 53
Joined: Sat Sep 17, 2005 6:08 pm
Location: Portugal

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by powerPT » Wed Oct 07, 2009 12:32 am

I am using JFusion login module to login and this don´t works (joomla and vBulletin).

Actually, I was logged in Joomla and now I cannot logout, nothing appends if I click on the button! :(

powerPT
Joomla! Intern
Joomla! Intern
Posts: 53
Joined: Sat Sep 17, 2005 6:08 pm
Location: Portugal

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by powerPT » Wed Oct 07, 2009 12:49 am

After delete cookies this issue login/logout works, only in joomla. Dual login still don´t works.

thehulaqueen
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Mar 25, 2008 3:10 pm

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by thehulaqueen » Wed Oct 07, 2009 12:55 am

Sounds like you have some JFusion settings to fix! It took us many tries to get it all properly configured. Good luck. Alan who works with JFusion does paid work... maybe he'd help.

jkellz
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon Nov 16, 2009 8:00 am

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by jkellz » Mon Nov 16, 2009 8:12 am

Doing what mihajlovski suggested seemed to have worked until I realized I was having this problem:

http://forum.joomla.org/viewtopic.php?f=433&t=461048

mihajlovski
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Jun 26, 2009 10:36 pm
Location: Macedonia

Re: FEATURE REQ: Cookie settings in Global Configuration

Post by mihajlovski » Tue Nov 17, 2009 8:43 pm

jkellz wrote:Doing what mihajlovski suggested seemed to have worked until I realized I was having this problem:

http://forum.joomla.org/viewtopic.php?f=433&t=461048
The issue you are having is just how Joomla behaves. A fresh Joomla installation will do the exact same thing (at least on my server).
Forum signature rules: viewtopic.php?f=8&t=65


Locked

Return to “Feature Requests - White Papers - Archived”